ctrlplusb / react-universally

A starter kit for universal react applications.
MIT License
1.69k stars 243 forks source link

Next: Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead. #580

Closed mschipperheyn closed 6 years ago

mschipperheyn commented 6 years ago

I've upgraded to next and I'm getting this exception when running e.g. yarn run analyze:client

/projects/mm/node_modules/webpack/lib/webpack.js:162
            throw new RemovedPluginError(errorMessage);
            ^

Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.
    at Object.get [as UglifyJsPlugin] (/Users/Shared/java/projects/react/projects/mm/node_modules/webpack/lib/webpack.js:162:10)
    at /Users/Shared/java/projects/react/projects/mm/node_modules/offline-plugin/lib/service-worker.js:110:63
    at Array.some (<anonymous>)
    at ServiceWorker.addEntry (/Users/Shared/java/projects/react/projects/mm/node_modules/offline-plugin/lib/service-worker.js:109:42)
    at /Users/Shared/java/projects/react/projects/mm/node_modules/offline-plugin/lib/index.js:238:23
    at /Users/Shared/java/projects/react/projects/mm/node_modules/offline-plugin/lib/index.js:692:16
    at Array.map (<anonymous>)
    at OfflinePlugin.useTools (/Users/Shared/java/projects/react/projects/mm/node_modules/offline-plugin/lib/index.js:691:43)
    at /Users/Shared/java/projects/react/projects/mm/node_modules/offline-plugin/lib/index.js:237:16
    at AsyncParallelHook.eval [as callAsync] (eval at create (/Users/Shared/java/projects/react/projects/mm/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:25:1)
    at AsyncParallelHook.lazyCompileHook [as _callAsync] (/Users/Shared/java/projects/react/projects/mm/node_modules/tapable/lib/Hook.js:35:21)
    at hooks.beforeCompile.callAsync.err (/Users/Shared/java/projects/react/projects/mm/node_modules/webpack/lib/Compiler.js:459:20)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/Shared/java/projects/react/projects/mm/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/Shared/java/projects/react/projects/mm/node_modules/tapable/lib/Hook.js:35:21)
    at Compiler.compile (/Users/Shared/java/projects/react/projects/mm/node_modules/webpack/lib/Compiler.js:452:28)
    at readRecords.err (/Users/Shared/java/projects/react/projects/mm/node_modules/webpack/lib/Compiler.js:200:11)

configFactory.js

[...]
optimization: {
      minimizer: ifProdClient([
        new UglifyJsPlugin({
          uglifyOptions: {
            ecma: 8,
            compress: {
              warnings: false,
              // Disabled because of an issue with Uglify breaking seemingly valid code:
              // https://github.com/facebook/create-react-app/issues/2376
              // Pending further investigation:
              // https://github.com/mishoo/UglifyJS2/issues/2011
              comparisons: false,
            },
            mangle: {
              safari10: true,
            },
            output: {
              comments: false,
              // Turned on because emoji and regex is not minified properly using default
              // https://github.com/facebook/create-react-app/issues/2488
              ascii_only: true,
            },
          },
          // Use multi-process parallel running to improve the build speed
          // Default number of concurrent runs: os.cpus().length - 1
          parallel: true,
          // Enable file caching
          cache: true,
          sourceMap: config('includeSourceMapsForOptimisedClientBundle'),
        }),
      ]),
    },
mschipperheyn commented 6 years ago

This was due to a not updated offline-plugin version