webpack.base.conf.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 'use strict'
  2. const path = require('path')
  3. const utils = require('./utils')
  4. const config = require('../config')
  5. const vueLoaderConfig = require('./vue-loader.conf')
  6. function resolve (dir) {
  7. return path.join(__dirname, '..', dir)
  8. }
  9. // const createLintingRule = () => ({
  10. // test: /\.(js|vue)$/,
  11. // loader: 'eslint-loader',
  12. // enforce: 'pre',
  13. // include: [resolve('src'), resolve('test')],
  14. // options: {
  15. // formatter: require('eslint-friendly-formatter'),
  16. // emitWarning: !config.dev.showEslintErrorsInOverlay
  17. // }
  18. // })
  19. module.exports = {
  20. context: path.resolve(__dirname, '../'),
  21. entry: {
  22. app: './src/main.js'
  23. },
  24. externals: {
  25. "BMap": "BMap"
  26. },
  27. output: {
  28. path: config.build.assetsRoot,
  29. filename: '[name].js',
  30. publicPath: process.env.NODE_ENV === 'production'
  31. ? config.build.assetsPublicPath
  32. : config.dev.assetsPublicPath
  33. },
  34. resolve: {
  35. extensions: ['.js', '.vue', '.json'],
  36. alias: {
  37. 'vue$': 'vue/dist/vue.esm.js',
  38. '@': resolve('src'),
  39. }
  40. },
  41. module: {
  42. rules: [
  43. ...(config.dev.useEslint ? [] : []),
  44. {
  45. test: /\.vue$/,
  46. loader: 'vue-loader',
  47. options: vueLoaderConfig
  48. },
  49. {
  50. test: /\.js$/,
  51. loader: 'babel-loader?cacheDirectory',
  52. include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
  53. },
  54. {
  55. test: /\.svg$/,
  56. loader: 'svg-sprite-loader',
  57. include: [resolve('src/icons')],
  58. options: {
  59. symbolId: 'icon-[name]'
  60. }
  61. },
  62. {
  63. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  64. loader: 'url-loader',
  65. exclude: [resolve('src/icons')],
  66. options: {
  67. limit: 10000,
  68. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  69. }
  70. },
  71. {
  72. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  73. loader: 'url-loader',
  74. options: {
  75. limit: 10000,
  76. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  77. }
  78. },
  79. {
  80. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  81. loader: 'url-loader',
  82. options: {
  83. limit: 10000,
  84. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  85. }
  86. },
  87. {
  88. test: /\.sass$/,
  89. loaders: ['style', 'css', 'sass']
  90. }
  91. ]
  92. },
  93. node: {
  94. // prevent webpack from injecting useless setImmediate polyfill because Vue
  95. // source contains it (although only uses it if it's native).
  96. setImmediate: false,
  97. // prevent webpack from injecting mocks to Node native modules
  98. // that does not make sense for the client
  99. dgram: 'empty',
  100. fs: 'empty',
  101. net: 'empty',
  102. tls: 'empty',
  103. child_process: 'empty'
  104. }
  105. }