Skip to content

Commit eba2b35

Browse files
authored
Merge pull request #305 from runarfu/issue-304-enable-debugger-with-flags-to-build-command
fix: Makes it possible to enable the Elm debugger with ELM_DEBUGGER=true
2 parents 1541ce2 + 9e6c8d4 commit eba2b35

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

config/webpack.config.prod.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const publicUrl = publicPath.slice(0, -1);
2424
// Get environment variables to inject into our app.
2525
const env = getClientEnvironment(publicUrl);
2626

27+
const useDebugger = process.env.ELM_DEBUGGER === 'true' ? true : false;
28+
2729
// Enable users to turn on dead code elimination.
2830
const deadCodeElimination =
2931
process.env.DEAD_CODE_ELIMINATION === 'true'
@@ -213,8 +215,8 @@ module.exports = {
213215
options: {
214216
// If ELM_DEBUGGER was set to "true", enable it. Otherwise
215217
// for invalid values, "false" and as a default, disable it
216-
debug: process.env.ELM_DEBUGGER === 'true' ? true : false,
217-
optimize: true,
218+
debug: useDebugger,
219+
optimize: !useDebugger,
218220
pathToElm: paths.elm
219221
}
220222
}

scripts/build.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,14 @@ measureFileSizesBeforeBuild(paths.appBuild)
8282

8383
// Create the production build and print the deployment instructions.
8484
function build(previousFileSizes) {
85-
console.log(`Creating an optimized ${process.env.NODE_ENV} build...`);
85+
const withDebugger = process.env.ELM_DEBUGGER === 'true' ? true : false;
86+
if (withDebugger) {
87+
console.log(
88+
`Creating a ${process.env.NODE_ENV} build with debugger enabled...`
89+
);
90+
} else {
91+
console.log(`Creating an optimized ${process.env.NODE_ENV} build...`);
92+
}
8693

8794
const compiler = webpack(config);
8895
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)