webpack.config.prod.js 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. output: {
  9. publicPath: '/'
  10. },
  11. optimization: {
  12. splitChunks: {
  13. cacheGroups: {
  14. commons: {
  15. test: /[\\/]node_modules[\\/]/,
  16. name: "vendor",
  17. chunks: "all",
  18. },
  19. },
  20. },
  21. },
  22. module: {
  23. rules: [
  24. {
  25. test: /\.css?$/,
  26. use: [
  27. MiniCssExtractPlugin.loader,
  28. 'css-loader'
  29. ]
  30. }, {
  31. test: /\.scss$/,
  32. use: [
  33. MiniCssExtractPlugin.loader,
  34. 'css-loader',
  35. 'sass-loader'
  36. ]
  37. }
  38. ]
  39. },
  40. plugins: [
  41. new MiniCssExtractPlugin({
  42. filename: 'main.css'
  43. }),
  44. new webpack.DefinePlugin({
  45. "process.env": "'prod'"
  46. })
  47. ]
  48. })