Skip to content

Commit

Permalink
Fix minifying issue
Browse files Browse the repository at this point in the history
  • Loading branch information
byronantak committed Oct 23, 2024
1 parent 2147df8 commit 7343d96
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
22 changes: 16 additions & 6 deletions webapp/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
var path = require('path');
var webpack = require("webpack");
const path = require('path');
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");

module.exports = function (env) {
module.exports = (env) => {
env = env || {};

const isProdEnv = Boolean(env.production)
const config = {
entry: {
'app': path.resolve(__dirname, './src/main/resources/public/js/app.js'),
Expand All @@ -15,7 +17,7 @@ module.exports = function (env) {
filename: 'js/[name]-[contenthash].js',
chunkFilename: 'js/[name]-[chunkhash].js'
},
mode: env.production ? 'production' : 'development',
mode: isProdEnv ? 'production' : 'development',
module: {
rules: [
{
Expand Down Expand Up @@ -102,18 +104,26 @@ module.exports = function (env) {
},
]
},
optimization: {
minimizer: [new TerserPlugin()],
minimize: isProdEnv,
},
performance: {
hints: 'error',
maxEntrypointSize: 1_800_000, // 1.8MB
maxAssetSize: 1_800_000 // 1.8MB
},
plugins: []
};


const HtmlWebpackPlugin = require('html-webpack-plugin');
config.plugins.push(new HtmlWebpackPlugin({
filename: path.resolve(__dirname, './target/classes/templates/index.html'),
template: 'src/main/resources/templates/index.html',
inject: false
}));

if (env.production) {
if (isProdEnv) {
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
Expand Down
26 changes: 17 additions & 9 deletions webapp/webpack.config_ict.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var path = require('path');
var webpack = require("webpack");
const path = require('path');
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");


module.exports = function (env) {
env = env || {};

var config = {

const isProdEnv = Boolean(env.production)
const config = {
entry: {
'ict-popup': path.resolve(__dirname, './src/main/resources/public/js/ict/chrome-ict-popup.js'),
'ict': path.resolve(__dirname, './src/main/resources/public/js/ict/chrome-ict.js')
Expand All @@ -14,11 +17,7 @@ module.exports = function (env) {
publicPath: '',
filename: '[name]-bundle.js',
},
performance: {
maxEntrypointSize: 900000, // 90KB
maxAssetSize: 900000 // 90KB
},
mode: env.production ? 'production' : 'development',
mode: isProdEnv ? 'production' : 'development',
module: {
rules: [
{
Expand Down Expand Up @@ -105,6 +104,15 @@ module.exports = function (env) {
},
]
},
optimization: {
minimizer: [new TerserPlugin()],
minimize: isProdEnv,
},

performance: {
maxEntrypointSize: 900_000, // 90KB
maxAssetSize: 900_000 // 90KB
},
plugins: []
};

Expand Down

0 comments on commit 7343d96

Please sign in to comment.