webpack.config.prod.js 933 B

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