From 72a7751a1a2c6ea01ad09cf45177e77d4155ccb4 Mon Sep 17 00:00:00 2001 From: Jonny Buchanan Date: Sun, 11 Mar 2018 07:09:22 +1000 Subject: [PATCH] Use production mode for all UMD builds Webpack 4's new development mode defaults aren't suitable for publishing Added the ability to disable uglification from build config --- src/createWebpackConfig.js | 4 ++-- src/moduleBuild.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/createWebpackConfig.js b/src/createWebpackConfig.js index 476e21b7..37ccd63f 100644 --- a/src/createWebpackConfig.js +++ b/src/createWebpackConfig.js @@ -528,8 +528,8 @@ export function createPlugins( debug: false, minimize: true, })) - optimization.minimize = userConfig.uglify !== false - if (userConfig.uglify !== false) { + optimization.minimize = buildConfig.uglify !== false && userConfig.uglify !== false + if (buildConfig.uglify !== false && userConfig.uglify !== false) { optimization.minimizer = [{ apply(compiler: any) { // Lazy load the uglifyjs plugin diff --git a/src/moduleBuild.js b/src/moduleBuild.js index 7e0a5a82..4da98e51 100644 --- a/src/moduleBuild.js +++ b/src/moduleBuild.js @@ -81,10 +81,11 @@ function buildUMD(args, buildConfig, userConfig, cb) { polyfill: false, plugins: { banner: createBanner(pkg), + uglify: false, }, } - process.env.NODE_ENV = 'development' + process.env.NODE_ENV = 'production' webpackBuild(null, args, webpackBuildConfig, (err, stats1) => { if (err) { spinner.fail() @@ -98,10 +99,10 @@ function buildUMD(args, buildConfig, userConfig, cb) { return cb() } - process.env.NODE_ENV = 'production' webpackBuildConfig.babel = merge(buildConfig.babel, buildConfig.babelProd || {}) webpackBuildConfig.devtool = 'source-map' webpackBuildConfig.output.filename = `${pkg.name}.min.js` + webpackBuildConfig.plugins.uglify = true webpackBuild(null, args, webpackBuildConfig, (err, stats2) => { if (err) { spinner.fail()