webpack.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const path = require("path");
  2. const TerserJSPlugin = require('terser-webpack-plugin');
  3. const HtmlPlugin = require("html-webpack-plugin");
  4. const HtmlPrefixPlugin = require("html-webpack-prefix-plugin");
  5. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  6. const CleanWebpackPlugin = require("clean-webpack-plugin");
  7. const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
  8. module.exports = {
  9. plugins: [
  10. new CleanWebpackPlugin(),
  11. new HtmlPlugin({template: "./ui/masterpage_template.tpl", prefix: 'ui/', filename: "../masterpage.tpl"}),
  12. new HtmlPrefixPlugin(),
  13. new MiniCssExtractPlugin({filename: "styles.[contenthash].css"})
  14. ],
  15. module: {
  16. rules: [
  17. {
  18. // For css...
  19. test: /\.(css|scss)$/,
  20. // ...use this loaders
  21. use: [
  22. {loader: "style-loader"},
  23. MiniCssExtractPlugin.loader,
  24. {loader: "css-loader", options: {url: false,}},
  25. "sass-loader"
  26. ]
  27. }
  28. ]
  29. },
  30. optimization: {
  31. minimizer: [
  32. new TerserJSPlugin(
  33. // Discard Comments
  34. {terserOptions: {output: {comments: false}}, parallel: 4}
  35. ),
  36. new OptimizeCSSAssetsPlugin(
  37. // Discard Comments
  38. {cssProcessorPluginOptions: {preset: ['default', {discardComments: {removeAll: true}}],}}
  39. )
  40. ],
  41. },
  42. entry: "./ui/js/index.js",
  43. output: {
  44. path: path.resolve(__dirname, "ui/dist/"),
  45. filename: "bundle.[contenthash].js"
  46. },
  47. mode: "production"
  48. };