webpack.common.js 1.7 KB

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