webpack.common.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const { HTMLWebpackPlugins, entry } = require('./_build/genMultiEntry.js')
  2. const VueLoaderPlugin = require('vue-loader/lib/plugin')
  3. const path = require('path')
  4. module.exports = {
  5. entry: entry,
  6. output: {
  7. filename: 'js/[name]_[hash:5].js',
  8. chunkFilename: 'js/[name]_[contenthash:5].js'
  9. },
  10. resolve: {
  11. alias: {
  12. '@': path.resolve(__dirname, 'src')
  13. }
  14. },
  15. optimization: {
  16. splitChunks: {
  17. chunks: 'all',
  18. cacheGroups: {
  19. commons: {
  20. test: /[\\/]node_modules[\\/]/,
  21. priority: -10,
  22. name: 'commons'
  23. }
  24. }
  25. }
  26. },
  27. module: {
  28. rules: [
  29. {
  30. test: /\.js$/,
  31. exclude: /node_modules/,
  32. use: [
  33. 'babel-loader',
  34. {
  35. loader: 'eslint-loader',
  36. options: {
  37. fix: true
  38. }
  39. }
  40. ]
  41. },
  42. {
  43. test: /\.vue$/,
  44. loader: 'vue-loader'
  45. },
  46. {
  47. test: /\.html$/,
  48. use: {
  49. loader: 'html-loader',
  50. options: {
  51. attrs: [':src']
  52. }
  53. }
  54. },
  55. {
  56. test: /\.(svg|jpe?g|gif|png|bmp)$/,
  57. use: {
  58. loader: 'url-loader',
  59. options: {
  60. name: '[name]_[hash:5].[ext]',
  61. outputPath: 'images',
  62. limit: 2048
  63. }
  64. }
  65. },
  66. {
  67. test: /\.(eot|ttf|woff2?|otf)$/,
  68. use: {
  69. loader: 'file-loader',
  70. options: {
  71. name: '[name]_[hash:5].[ext]',
  72. outputPath: 'fonts'
  73. }
  74. }
  75. }
  76. ]
  77. },
  78. plugins: [
  79. ...HTMLWebpackPlugins,
  80. new VueLoaderPlugin()
  81. ]
  82. }