Skip to content

Commit

Permalink
Merge pull request #186 from halfzebra/disablinb-dead-code-elimination
Browse files Browse the repository at this point in the history
feat($config): Enable users to disable dead code elimination by setti…
  • Loading branch information
halfzebra authored Oct 31, 2017
2 parents 3813c89 + a7493be commit 0486adf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
56 changes: 33 additions & 23 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
{ publicPath: Array(cssFilename.split('/').length).join('../') }
: {};

// Enable users to turn off dead code elimination.
const deadCodeElimination =
process.env.DEAD_CODE_ELIMINATION !== 'true'
? {
dead_code: true,
pure_funcs: [
'_elm_lang$core$Native_Utils.update',
'A2',
'A3',
'A4',
'A5',
'A6',
'A7',
'A8',
'A9',
'F2',
'F3',
'F4',
'F5',
'F6',
'F7',
'F8',
'F9'
]
}
: {};

module.exports = {
// Don't attempt to continue if there are any errors.
bail: true,
Expand Down Expand Up @@ -185,29 +212,12 @@ module.exports = {

// Minify the compiled JavaScript.
new UglifyJsPlugin({
compress: {
warnings: false,
dead_code: true,
pure_funcs: [
'_elm_lang$core$Native_Utils.update',
'A2',
'A3',
'A4',
'A5',
'A6',
'A7',
'A8',
'A9',
'F2',
'F3',
'F4',
'F5',
'F6',
'F7',
'F8',
'F9'
]
},
compress: Object.assign(
{
warnings: false
},
deadCodeElimination
),
output: {
comments: false
}
Expand Down
7 changes: 7 additions & 0 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ You can find the most recent version of this guide [here](https://github.com/hal
- [make](#make)
- [reactor](#reactor)
- [Turning on/off Elm Debugger](#turning-onoff-elm-debugger)
- [Dead code elimination](#dead-code-elimination)
- [Changing the Page `<title>`](#changing-the-page-title)
- [Adding a Stylesheet](#adding-a-stylesheet)
- [Post-Processing CSS](#post-processing-css)
Expand Down Expand Up @@ -168,6 +169,12 @@ By default, in production (`elm-app build`) the Debugger is turned off and in de

To turn on/off Elm Debugger explicitly, set `ELM_DEBUGGER` environment variable to `true` or `false` respectively.

## Dead code elimination

Create Elm App comes with an opinionated setup for dead code elimination which is disabled by default, because it may break your code.

You can enable it by setting `DEAD_CODE_ELIMINATION` environment variable to `true`

## Changing the base path of the assets in the HTML

By default, assets will be linked from the HTML to the root url. For example `/css/style.css`.
Expand Down

0 comments on commit 0486adf

Please sign in to comment.