Created
December 18, 2020 11:57
-
-
Save fluidsonic/9c0da516acd9e3664e3c22a802f4def4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;+function () { | |
// noinspection JSUnresolvedFunction,NpmUsedModulesInstalled | |
const TerserPlugin = require('terser-webpack-plugin') | |
// noinspection JSUnresolvedVariable | |
if (config.mode === 'production') { | |
// noinspection JSUnresolvedVariable,SpellCheckingInspection,JSUnusedGlobalSymbols | |
config.optimization = { | |
minimize: true, | |
minimizer: [ | |
new TerserPlugin({ | |
terserOptions: { | |
// ecma: "2016", // doesn't work with hack in fluid-css: js("Stylis = Stylis.default") | |
compress: { | |
keep_fargs: false, | |
negate_iife: false, | |
passes: 5, // 4 was highest number observed to date that results in even smaller code | |
pure_funcs(node) { | |
// noinspection JSUnresolvedVariable | |
return ![ | |
'isObject', | |
'KClass', | |
'KClassImpl', | |
'KClassifier', | |
'Unit', | |
'Unit_getInstance', | |
'getKPropMetadata', | |
'getPropertyCallableRef', | |
'getPropertyRefClass', | |
'propertyRefClassMetadataCache$init$' | |
].includes(node.expression.name) | |
}, | |
pure_getters: true, | |
unsafe: true, | |
unsafe_arrows: true, | |
unsafe_methods: true, | |
unsafe_proto: true, | |
unsafe_symbols: true, | |
}, | |
format: { | |
beautify: false, // for debugging | |
wrap_func_args: false, | |
wrap_iife: true, | |
}, | |
mangle: { | |
keep_classnames: false, // for debugging | |
keep_fnames: false, // for debugging | |
}, | |
}, | |
}), | |
], | |
splitChunks: { | |
cacheGroups: { | |
vendors: false, | |
}, | |
}, | |
} | |
// noinspection SpellCheckingInspection,JSUnresolvedVariable | |
config.output.chunkFilename = `assets/[chunkhash].js` | |
} | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment