webpack.prod.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const merge = require('webpack-merge')
  2. const commonConf = require('./webpack.common.js')
  3. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  4. const TerserJSPlugin = require('terser-webpack-plugin')
  5. const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
  6. const CopyWebpackPlugin = require('copy-webpack-plugin')
  7. const path = require('path')
  8. const prodConf = {
  9. mode: 'production',
  10. devtool: 'cheap-module-source-map',
  11. output: {
  12. path: path.resolve(__dirname, '../../../pub/zq2019/lolSkinShow'),
  13. publicPath: `//pub.dwstatic.com/zq2019/lolSkinShow/`
  14. },
  15. module: {
  16. rules: [
  17. {
  18. test: /\.(scss|css)$/,
  19. use: [
  20. MiniCssExtractPlugin.loader,
  21. {
  22. loader: 'css-loader',
  23. options: {
  24. importLoaders: 2
  25. }
  26. },
  27. 'sass-loader',
  28. 'postcss-loader'
  29. ]
  30. },
  31. {
  32. test: /\.module\.(scss|css)$/,
  33. use: [
  34. MiniCssExtractPlugin.loader,
  35. {
  36. loader: 'css-loader',
  37. options: {
  38. importLoaders: 2,
  39. modules: true
  40. }
  41. },
  42. 'sass-loader',
  43. 'postcss-loader'
  44. ]
  45. }
  46. ]
  47. },
  48. plugins: [
  49. new MiniCssExtractPlugin({
  50. filename: 'css/[name]_[hash:5].css',
  51. chunkFilename: 'css/[id]_[hash:5].css'
  52. }),
  53. new CopyWebpackPlugin([
  54. { from: 'src/assets/duowanFooter.min.js', to: 'js' }
  55. ])
  56. ],
  57. optimization: {
  58. minimizer: [
  59. new TerserJSPlugin({
  60. sourceMap: true
  61. }),
  62. new OptimizeCSSAssetsPlugin({})
  63. ]
  64. }
  65. }
  66. module.exports = merge(commonConf, prodConf)