webpack.base.conf.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. }
  27. },
  28. module: {
  29. rules: [
  30. {
  31. test: /\.vue$/,
  32. loader: 'vue-loader',
  33. options: vueLoaderConfig
  34. },
  35. {
  36. test: /\.js$/,
  37. loader: 'babel-loader',
  38. include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
  39. },
  40. {
  41. test: /\.svg$/,
  42. loader: 'svg-sprite-loader',
  43. include: [resolve('src/icons')],
  44. options: {
  45. symbolId: 'icon-[name]'
  46. }
  47. },
  48. {
  49. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  50. loader: 'url-loader',
  51. exclude: resolve('src/icons'),
  52. options: {
  53. limit: 10000,
  54. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  55. }
  56. },
  57. {
  58. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  59. loader: 'url-loader',
  60. options: {
  61. limit: 10000,
  62. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  63. }
  64. },
  65. {
  66. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  67. loader: 'url-loader',
  68. options: {
  69. limit: 10000,
  70. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  71. }
  72. }
  73. ]
  74. },
  75. node: {
  76. // prevent webpack from injecting useless setImmediate polyfill because Vue
  77. // source contains it (although only uses it if it's native).
  78. setImmediate: false,
  79. // prevent webpack from injecting mocks to Node native modules
  80. // that does not make sense for the client
  81. dgram: 'empty',
  82. fs: 'empty',
  83. net: 'empty',
  84. tls: 'empty',
  85. child_process: 'empty'
  86. }
  87. }