Skip to content
Permalink
Browse files

feat: pass the `terserOptions` to the `minify` option (#311)

  • Loading branch information
evilebottnawi committed Sep 11, 2020
1 parent defde64 commit 4bd622cdaeb51be5d5151925f64ac1054298a214
@@ -304,8 +304,13 @@ module.exports = {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
myCustomOption: true,
},
// Can be async
minify: (file, sourceMap) => {
minify: (file, sourceMap, minimizerOptions) => {
// The `minimizerOptions` option contains option from the `terserOptions` option
// You can use `minimizerOptions.myCustomOption`
const extractedComments = [];
// Custom logic for extract comments
@@ -141,14 +141,20 @@ const buildComments = (extractComments, terserOptions, extractedComments) => {
};

async function minify(options) {
const { name, input, inputSourceMap, minify: minifyFn } = options;
const {
name,
input,
inputSourceMap,
minify: minifyFn,
minimizerOptions,
} = options;

if (minifyFn) {
return minifyFn({ [name]: input }, inputSourceMap);
return minifyFn({ [name]: input }, inputSourceMap, minimizerOptions);
}

// Copy terser options
const terserOptions = buildTerserOptions(options.minimizerOptions);
const terserOptions = buildTerserOptions(minimizerOptions);

// Let terser generate a SourceMap
if (inputSourceMap) {

0 comments on commit 4bd622c

Please sign in to comment.
You can’t perform that action at this time.