webpack.prod.config.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const merge = require('webpack-merge');
  2. const common = require('./webpack.common.config.js');
  3. const HtmlWebpackPlugin = require('html-webpack-plugin');
  4. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  5. module.exports = merge(common, {
  6. optimization: {
  7. splitChunks: {
  8. chunks: 'all',
  9. minSize: 30000,
  10. maxSize: 0,
  11. minChunks: 1,
  12. cacheGroups: {
  13. framework: {
  14. test: "framework",
  15. name: "framework",
  16. enforce: true
  17. },
  18. vendors: {
  19. priority: -10,
  20. test: /node_modules/,
  21. name: "vendor",
  22. enforce: true,
  23. },
  24. }
  25. }
  26. },
  27. mode: 'production',
  28. output: {
  29. filename: 'nodejs/[name].[chunkhash:8].bundle.js',
  30. },
  31. plugins: [
  32. new HtmlWebpackPlugin({
  33. filename: 'index.html',
  34. template: 'public/index.html',
  35. chunks:['workbench','framework'],
  36. // inject: 'body',
  37. // minify: {
  38. // removeComments: true,
  39. // collapseWhitespace: true,
  40. // },
  41. })
  42. //,new CleanWebpackPlugin()
  43. ]
  44. });