-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace NODE_ENV with mode #49
Conversation
Codecov Report
@@ Coverage Diff @@
## master #49 +/- ##
==========================================
+ Coverage 98.78% 98.83% +0.05%
==========================================
Files 2 2
Lines 82 86 +4
==========================================
+ Hits 81 85 +4
Misses 1 1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! :)
I believe the mode -> env mapping should be different
Also can you update the readme
test/core.js
Outdated
test.serial('with NODE_ENV=production', async t => { | ||
process.env.NODE_ENV = 'production'; | ||
|
||
test.serial('with mode=production', async t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove serial
now
src/index.js
Outdated
@@ -34,7 +34,7 @@ export default class DynamicCdnWebpackPlugin { | |||
|
|||
apply(compiler) { | |||
if (!this.disable) { | |||
this.execute(compiler, {env: this.env}); | |||
this.execute(compiler, {env: this.env || compiler.options.mode || 'production'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here how compiler.options.mode
I believe should map:
none
:development
undefined
:production
production and development stays the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably moving the logic into its own function will make it nicer?
Updated the README and moved the mapping logic to a function. |
readme.md
Outdated
@@ -158,7 +158,7 @@ Usefull when working offline, will fallback to webpack normal behaviour | |||
#### options.env | |||
|
|||
Type: `string`<br> | |||
Default: `process.env.NODE_ENV || 'development'`<br> | |||
Default: `mode` used by webpack<br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ideas on the wording here? I really couldn't think of much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we've done it: https://github.com/danethurber/webpack-manifest-plugin#optionspublicpath
With the pseudo code at the beginning: https://github.com/danethurber/webpack-manifest-plugin#api
I believe we are good to go! :D |
Towards closing #40.
The breaking change is that I'm defaulting to
production
when an environment is not specified. Since webpack >= 4 does the same whenmode
is omitted, I believe we can do the same thing.I don't think there is any webpack <= 3 code left to change. README will need to be updated - I think a separate PR will be needed since there'll be other changes to be added in the README once #40 is done.