webpack.base.conf.js 2.0 KB

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