Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Automatically use appropriate webpack mode based on run/build #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ChainsDD
Copy link

@ChainsDD ChainsDD commented Aug 17, 2018

This pull request changes the default behavior of the webpack bundler to switch it's mode based on if you're running the dev server or building the bundle. I removed the mode line from webpack.config.js, instead either specifying it from the command line (when building), or injecting it into the config object in webpack-dev-server-run.js. Both methods are only used if webpack 4+ is being used. Setting a mode in build.gradle will cause that mode to be used in both cases.

I felt this was a necessary change, as there isn't a simple method of changing webpack's mode based on build type. This seems like a reasonable expected behavior when the plugin is already handling most of webpack's other configuration automatically.

I also pulled the webpack version check out of WebPackBundleTask.kt into it's own class, since it's being used in two places now. The new NpmModuleVersion class can be used to check the major, minor, and patch number of any installed npm module, so I moved it to the npm package. I didn't look through to see if that kind of check was being performed anywhere else in the codebase, but it's there if needed.

testSimpleProjectWebPackBundleWithDce had to be modified to pass, since the output bundle was now being minified. This was causing the last assertion to fail, since "usedFunction2222" was being changed to something shorter. Whatever it's changed to may not be consistent with different versions of webpack or it's minifier, so checking for a certain output would make the test fragile. Instead I just set the test so that webpack runs in development mode, which disables the minifier.

testSimpleProjectWebPackBundleWithDce had to be modified to pass, since the output bundle was now being minified. This was causing the last assertion to fail, since "usedFunction2222" was being changed to something shorter.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant