Skip to content
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

Merged
merged 4 commits into from
Aug 28, 2018
Merged

replace NODE_ENV with mode #49

merged 4 commits into from
Aug 28, 2018

Conversation

aulisius
Copy link
Collaborator

@aulisius aulisius commented Aug 26, 2018

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 when mode 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.

@codecov-io
Copy link

codecov-io commented Aug 26, 2018

Codecov Report

Merging #49 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/index.js 98.79% <100%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 124e6f9...aa0913d. Read the comment docs.

Copy link
Owner

@mastilver mastilver left a 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 => {
Copy link
Owner

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'});
Copy link
Owner

@mastilver mastilver Aug 26, 2018

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

Copy link
Owner

@mastilver mastilver Aug 26, 2018

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?

@aulisius
Copy link
Collaborator Author

aulisius commented Aug 26, 2018

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>
Copy link
Collaborator Author

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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aulisius
Copy link
Collaborator Author

I believe we are good to go! :D

@mastilver mastilver merged commit 4226565 into mastilver:master Aug 28, 2018
@aulisius aulisius deleted the use-mode-over-node-env branch August 28, 2018 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants