From 9e6c8d440738e90e1026342fdfcea423755a9d87 Mon Sep 17 00:00:00 2001 From: Runar Furenes Date: Tue, 25 Sep 2018 12:46:14 +0200 Subject: [PATCH] fix: Makes it possible to enable the Elm debugger with ELM_DEBUGGER=true fix #304 --- config/webpack.config.prod.js | 6 ++++-- scripts/build.js | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index 8382f93d..bf5c1b7e 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -24,6 +24,8 @@ const publicUrl = publicPath.slice(0, -1); // Get environment variables to inject into our app. const env = getClientEnvironment(publicUrl); +const useDebugger = process.env.ELM_DEBUGGER === 'true' ? true : false; + // Enable users to turn on dead code elimination. const deadCodeElimination = process.env.DEAD_CODE_ELIMINATION === 'true' @@ -213,8 +215,8 @@ module.exports = { options: { // If ELM_DEBUGGER was set to "true", enable it. Otherwise // for invalid values, "false" and as a default, disable it - debug: process.env.ELM_DEBUGGER === 'true' ? true : false, - optimize: true, + debug: useDebugger, + optimize: !useDebugger, pathToElm: paths.elm } } diff --git a/scripts/build.js b/scripts/build.js index 9a6d90ca..11e8796c 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -82,7 +82,14 @@ measureFileSizesBeforeBuild(paths.appBuild) // Create the production build and print the deployment instructions. function build(previousFileSizes) { - console.log(`Creating an optimized ${process.env.NODE_ENV} build...`); + const withDebugger = process.env.ELM_DEBUGGER === 'true' ? true : false; + if (withDebugger) { + console.log( + `Creating a ${process.env.NODE_ENV} build with debugger enabled...` + ); + } else { + console.log(`Creating an optimized ${process.env.NODE_ENV} build...`); + } const compiler = webpack(config); return new Promise((resolve, reject) => {