How to minify workers loaded by worker-loader

Viewed 282

I'm using worker-loader to import workers into what is otherwise very close to original create-react-app webpack config.

However, I noticed that the workers aren't being minified in production. It seems that in very old versions of the loader, plugins could be passed to it via options, but that is no longer the case. How do I make sure that UglifyJSPlugin is applied to worker file as well?

My prod config is roughly as follows:

module.exports = {
  ...
  module: {
    rules: [
      {
        test: /\.worker\.js$/,
        use: {
          loader: 'worker-loader',
        },
      },
      ...
    ],
  },
  plugins: [
    ...
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
        comparisons: false,
      },
      output: {
        comments: false,
        ascii_only: true,
      },
      sourceMap: false,
    }),
  ...
0 Answers
Related