Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webpack5] Type 'TerserPlugin' is not assignable to optimization.minimizer option #333

Closed
tjx666 opened this issue Oct 13, 2020 · 5 comments

Comments

@tjx666
Copy link

tjx666 commented Oct 13, 2020

  • Operating System: win10 pro
  • Node Version: v12.19.0
  • NPM Version: 6.14.8
  • webpack Version: ^5.1.0
  • terser-webpack-plugin Version: ^4.2.3

Expected Behavior

No TypeScript Error reported.

Actual Behavior

screenshot_2020-10-14_00-26-55

Code

import { argv } from 'yargs';
import { BannerPlugin, Configuration } from 'webpack';
import { merge } from 'webpack-merge';
import TerserPlugin from 'terser-webpack-plugin';
import SpeedMeasurePlugin from 'speed-measure-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';

import commonWebpackConfig from './webpack.common';

const mergedConfiguration: Configuration = merge(commonWebpackConfig, {
    mode: 'production',
    plugins: [
        new BannerPlugin({
            banner:
                '/** @preserve powered by vscode-extension-boilerplate(https://github.com/tjx666/vscode-extension-boilerplate) */',
            raw: true,
        }),
    ],
    optimization: {
        minimize: true,
        minimizer: [
            new TerserPlugin({
                cache: true,
                parallel: true,
                extractComments: false,
            }),
        ],
    },
});

// eslint-disable-next-line import/no-mutable-exports
let prodWebpackConfiguration = mergedConfiguration;
if (argv.analyze) {
    mergedConfiguration.plugins!.push(new BundleAnalyzerPlugin());
    const smp = new SpeedMeasurePlugin();
    prodWebpackConfiguration = smp.wrap(mergedConfiguration);
}

export default prodWebpackConfiguration;

How Do We Reproduce?

Project Address: vscode-extension-boilerplate

@alexander-akait
Copy link
Member

Not related to terser-webpack-plugin, we don't have types

@alexander-akait
Copy link
Member

You need to wait updating @types

@grantila
Copy link

Specifically this DefinitelyTyped/DefinitelyTyped#48806

@brunomarks7
Copy link

brunomarks7 commented Dec 2, 2020

If do you use Webpack 5, you don't need the terser-webpack-plugin.
https://webpack.js.org/plugins/terser-webpack-plugin/

image

@ghost
Copy link

ghost commented Aug 5, 2021

如果您使用 Webpack 5,则不需要 terser-webpack-plugin。
https://webpack.js.org/plugins/terser-webpack-plugin/

图像

I need to update the terser options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants