webpack.config.js 1.4 KB

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