webpack.base.conf.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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: /\.(png|jpe?g|gif|svg|pdf)(\?.*)?$/,
  42. loader: 'url-loader',
  43. options: {
  44. limit: 10000,
  45. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  46. }
  47. },
  48. {
  49. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  50. loader: 'url-loader',
  51. options: {
  52. limit: 10000,
  53. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  54. }
  55. },
  56. {
  57. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  58. loader: 'url-loader',
  59. options: {
  60. limit: 10000,
  61. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  62. }
  63. },
  64. {
  65. test: /\.less$/,
  66. use: [{
  67. loader: "style-loader"
  68. }, {
  69. loader: "css-loader"
  70. }, {
  71. loader: "less-loader"
  72. }]
  73. },
  74. ]
  75. },
  76. node: {
  77. // prevent webpack from injecting useless setImmediate polyfill because Vue
  78. // source contains it (although only uses it if it's native).
  79. setImmediate: false,
  80. // prevent webpack from injecting mocks to Node native modules
  81. // that does not make sense for the client
  82. dgram: 'empty',
  83. fs: 'empty',
  84. net: 'empty',
  85. tls: 'empty',
  86. child_process: 'empty'
  87. }
  88. }