Skip to content

Commit

Permalink
Use production mode for all UMD builds
Browse files Browse the repository at this point in the history
Webpack 4's new development mode defaults aren't suitable for publishing

Added the ability to disable uglification from build config
  • Loading branch information
insin committed Mar 11, 2018
1 parent 16849ef commit 558e36b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/createWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/moduleBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 558e36b

Please sign in to comment.