You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webpack.base.conf.js 2.1KB

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