webpack.base.conf.js 2.3 KB

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