-
Notifications
You must be signed in to change notification settings - Fork 22
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
Restructure webpack configuration #82
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit is only supposed to restructure the way we write webpack configuration. There should be no change in the actual contents of the configuration. The file structure has changed to make it clear where to look when looking for a specific piece of config: - webpack.conf.dev.js and webpack.conf.prod.js now only serve as entry files. They do not contain configuration - webpack.conf.base.js only contains top-level configuration properties - all other configuration has been split into the top-level objects of a webpack config file to webpack.partial.conf.<prop>.js The filenames have been changed to start with webpack.conf instead of ending in .conf. This will make sure that all the webpack.partial.conf files are next to each other when sorted alphabetically. All helper functions (mostly for loaders) have been moved to be inline at the location where they are used. This will make sure all the configuration related to a single property is next to each other (as opposed to split among different modules) A small number of conf options have been removed that are already automatically set by webpack when using the 'mode' property. Comment blocks have been added in several places to create a visual separation in long configuration files.
ThaNarie
suggested changes
Oct 17, 2018
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.
I think I like the change :)
jesse-mm
reviewed
Oct 17, 2018
jesse-mm
reviewed
Oct 17, 2018
Nice work and I like the approach of separation for the configuration options of webpack. 👍 |
Instead of passing an isDevelopment flag to webpack.conf.base.js, we now pass a buildType string which (by default) can be either 'development' or 'production'. This leaves room for more complex build setups where more types of builds are desirable. The partial files will now also receive the `buildType` string. Because the buildType in most cases is either development or production, the `isDevelopment` boolean is also passed to the partials for convenience. The `dev` and `build` objects of `config.js` have been slightly refactored and renamed for clarity. - because `env` exists in both of these, it is moved one level up. The distinction between build types is made inside of the `env` object instead - `dev` has been renamed to `devServer`, to indicate that these options are specifically meant for the webpack development server (as opposed to development builds, which can theoratically also be deployed). - `build` has been renamed to `dist` (technically a dev server is also a "build", so that term is a bit too generic)
This plugin needs to be injected from webpack.conf.dev, because the port number needs to be passed to the success message. Added a comment to clarify this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
important: this PR should only change the structure of the configuration, the contents of the config should stay the same for now.
Motivation
I've noticed before that our webpack configuration can be somewhat hard to navigate. I wanted to start working on #57, but I'm afraid that making changes in our current webpack config setup will further complicate things. That's why I would like to introduce this change first. Here are some of the problems I am trying to solve:
webpack.base.conf
,webpack.dev.conf
orwebpack.prod.conf
.webpack.dev.conf
andwebpack.prod.conf
, sometimes they are inwebpack.base.conf
and switched using anisDevelopment
flag.webpackHelpers
). This made it difficult to debug configuration issues because you had to keep clicking back and forth between different modules.Changes
File structure
The file structure has changed to make it clear where to look when looking for a specific piece of config:
webpack.conf.dev.js
andwebpack.conf.prod.js
now only serve as entry files. They do not contain configurationwebpack.conf.base.js
only contains top-level configuration properties (mode
anddevtool
)webpack.partial.conf.<prop>.js
webpack.conf
instead of ending in.conf
. This will make sure that all thewebpack.partial.conf
files are next to each other when sorted alphabetically.Use of helper functions
All helper functions (mostly for loaders) have been moved to be inline at the location where they are used. This will make sure all the configuration related to a single property is next to each other (as opposed to split among different modules). For example:
An iife (
(() => { ... })()
) is used here instead of agetSvgoLoaderConfig()
at the top of the file. This is to ensure that all the config related to.svg
is together.Small things
webpack.partial.conf.module.js
)