暫無描述

webpack.base.conf.js 2.1KB

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