webpack.base.conf.js 2.3 KB

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