webpack.base.conf.js 2.1 KB

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