webpack.config.prod.js 829 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict'
  2. const merge = require('webpack-merge')
  3. const baseConfig = require('./webpack.config.base')
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  5. module.exports = merge(baseConfig, {
  6. mode: 'production',
  7. optimization: {
  8. splitChunks: {
  9. cacheGroups: {
  10. commons: {
  11. test: /[\\/]node_modules[\\/]/,
  12. name: "vendor",
  13. chunks: "all",
  14. },
  15. },
  16. },
  17. },
  18. module: {
  19. rules: [
  20. {
  21. test: /\.css?$/,
  22. use: [
  23. MiniCssExtractPlugin.loader,
  24. 'css-loader'
  25. ]
  26. }, {
  27. test: /\.scss$/,
  28. use: [
  29. MiniCssExtractPlugin.loader,
  30. 'css-loader',
  31. 'sass-loader'
  32. ]
  33. }
  34. ]
  35. },
  36. plugins: [
  37. new MiniCssExtractPlugin({
  38. filename: 'main.css'
  39. })
  40. ]
  41. })