Skip to content

Commit 8528f92

Browse files
author
JelteMX
committed
Add build task for analysis && minification
1 parent 7542ceb commit 8528f92

File tree

3 files changed

+364
-11
lines changed

3 files changed

+364
-11
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"lint": "pluggable-widgets-tools lint",
2020
"lint:fix": "pluggable-widgets-tools lint:fix",
2121
"prerelease": "npm run lint",
22-
"release": "pluggable-widgets-tools release:ts"
22+
"release": "pluggable-widgets-tools release:ts",
23+
"analyze": "pluggable-widgets-tools release:ts --analyze"
2324
},
2425
"license": "Apache-2.0",
2526
"devDependencies": {
@@ -29,7 +30,9 @@
2930
"@types/jest": "^24.0.0",
3031
"@types/react": "~16.9.0",
3132
"@types/react-dom": "~16.9.0",
32-
"@types/react-test-renderer": "~16.9.0"
33+
"@types/react-test-renderer": "~16.9.0",
34+
"terser-webpack-plugin": "^3.0.6",
35+
"webpack-bundle-analyzer": "^3.8.0"
3336
},
3437
"dependencies": {
3538
"classnames": "^2.2.6",

webpack.config.prod.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const merge = require("webpack-merge");
2+
const webpack = require("webpack");
3+
const path = require("path");
4+
const pkg = require('./package.json');
5+
6+
const args = process.argv.slice(2);
7+
8+
const baseConfig = require("./node_modules/@mendix/pluggable-widgets-tools/configs/webpack.config.prod.js");
9+
10+
const TerserPlugin = require("terser-webpack-plugin");
11+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
12+
13+
const customConfig = {
14+
// Custom configuration goes here
15+
devtool: false,
16+
optimization: {
17+
minimizer: [
18+
new TerserPlugin({
19+
cache: true,
20+
parallel: true,
21+
extractComments: false,
22+
terserOptions: {
23+
ecma: undefined,
24+
warnings: false,
25+
sourceMap: false,
26+
parse: {},
27+
compress: {
28+
passes: 2
29+
},
30+
mangle: true,
31+
module: false,
32+
output: {
33+
comments: false,
34+
beautify: false,
35+
preamble: `/* Text Template Widget || Version ${pkg.version} || Apache 2 LICENSE || Developer: ${pkg.author} || Please report any issues here: https://github.com/JelteMX/mendix-text-template/issues */\n`
36+
},
37+
toplevel: false,
38+
nameCache: null,
39+
ie8: false,
40+
keep_classnames: undefined,
41+
keep_fnames: false,
42+
safari10: false
43+
},
44+
}),
45+
]
46+
},
47+
plugins: [
48+
49+
],
50+
// We add this to further slim down the package
51+
resolve: {
52+
alias: {
53+
54+
}
55+
}
56+
};
57+
58+
if (args.includes("--analyze")) {
59+
customConfig.plugins.push(new BundleAnalyzerPlugin());
60+
}
61+
62+
const previewConfig = {
63+
// Custom configuration goes here
64+
// devtool: "source-map"
65+
plugins: [
66+
67+
],
68+
resolve: {
69+
alias: {
70+
}
71+
}
72+
};
73+
74+
module.exports = [merge(baseConfig[0], customConfig), merge(baseConfig[1], previewConfig)];

0 commit comments

Comments
 (0)