From 9d643d6f51a2172098f5e66768ebef598fc24bac Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Wed, 14 Aug 2019 08:53:59 -0700 Subject: [PATCH 1/2] Enable production optimizations when compiling in production Smaller assets and better performance. More info here: https://elm-lang.org/0.19.0/optimize --- lib/install/loaders/elm.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/install/loaders/elm.js b/lib/install/loaders/elm.js index 4ca39e86e..9449a7ffb 100644 --- a/lib/install/loaders/elm.js +++ b/lib/install/loaders/elm.js @@ -9,10 +9,13 @@ const developmentOptions = Object.assign({}, elmDefaultOptions, { verbose: true, debug: true }) +const productionOptions = Object.assign({}, elmDefaultOptions, { + optimize: true +}) const elmWebpackLoader = { loader: 'elm-webpack-loader', - options: isProduction ? elmDefaultOptions : developmentOptions + options: isProduction ? productionOptions : developmentOptions } module.exports = { From 3024b2b7771b7bf934be716914bcabeb63d64b82 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Wed, 18 Sep 2019 09:56:29 +0100 Subject: [PATCH 2/2] Use the env flags instead --- lib/install/loaders/elm.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/install/loaders/elm.js b/lib/install/loaders/elm.js index 9449a7ffb..8447047bc 100644 --- a/lib/install/loaders/elm.js +++ b/lib/install/loaders/elm.js @@ -1,21 +1,21 @@ const { resolve } = require('path') const isProduction = process.env.NODE_ENV === 'production' +const isDevelopment = process.env.NODE_ENV === 'development' const elmSource = resolve(process.cwd()) const elmBinary = `${elmSource}/node_modules/.bin/elm` -const elmDefaultOptions = { cwd: elmSource, pathToElm: elmBinary } -const developmentOptions = Object.assign({}, elmDefaultOptions, { - verbose: true, - debug: true -}) -const productionOptions = Object.assign({}, elmDefaultOptions, { - optimize: true -}) +const options = { + cwd: elmSource, + pathToElm: elmBinary, + optimize: isProduction, + verbose: isDevelopment, + debug: isDevelopment +} const elmWebpackLoader = { loader: 'elm-webpack-loader', - options: isProduction ? productionOptions : developmentOptions + options: options } module.exports = {