webpack.prod.js 858 B

123456789101112131415161718192021222324252627282930313233
  1. const webpack = require('webpack')
  2. const merge = require('webpack-merge')
  3. const commonConf = require('./webpack.common.js')
  4. const TerserJSPlugin = require('terser-webpack-plugin')
  5. const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
  6. const {CleanWebpackPlugin} = require('clean-webpack-plugin')
  7. const path = require('path')
  8. const prodConf = {
  9. entry: {
  10. index: path.resolve(__dirname, 'src/index.ts')
  11. },
  12. mode: 'production',
  13. output: {
  14. filename: 'DWDanmu.min.js',
  15. path: path.resolve(__dirname, 'lib'),
  16. },
  17. plugins: [
  18. new CleanWebpackPlugin(),
  19. new webpack.DefinePlugin({
  20. DEV: JSON.stringify(false)
  21. })
  22. ],
  23. optimization: {
  24. minimizer: [
  25. new TerserJSPlugin({
  26. sourceMap: true
  27. }),
  28. new OptimizeCSSAssetsPlugin({})
  29. ]
  30. }
  31. }
  32. module.exports = merge(commonConf, prodConf)