webpack.base.conf.js 2.3 KB

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