-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSS Modules HMR working again (#3031)
* CSS Modules HMR working again 1. Use style-loader for CSS modules HMR 2. Don't extract CSS if running the webpack-dev-server * Clarify dev_server.running? first checks configured Webpacker.dev_server.running? might appear to be costly, but it first checks that the dev_server value is on the config Hash. Renaming the method makes it clear that the first check is whether it is configured. Since the dev_server would ever be configured on production, there is no cost for calling this method on production. * Simplifications and fixes for HMR * HMR default to true for webpacker.yml * inline, injectClient, and injectHot default to the value of hmr * hmr turned on for the webpack dev server if the hmr config is true * using command line option for --hot as the docs recommend that over the plugin. * Fix jest and ruby tests * Address review 1. hmr default is false 2. CSS is extracted unless yml file configuredd HMR and running webpack-dev-server * Address review comments * Refactor to allow exporting logic of inliningCss * Fix jest and Ruby tests * Update developing_webpacker.md * Update changelog
- Loading branch information
Showing
19 changed files
with
108 additions
and
35 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Developing Webpacker | ||
|
||
It's a little trickier for Rails developers to work on the JS code of a project like rails/webpacker. So here are some tips! | ||
|
||
## Use some test app | ||
For example, for React on Rails Changes, I'm using [shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh). | ||
This directory is the `TEST_APP_DIR`. | ||
|
||
## Fork rails/webpacker | ||
Let's call the rails/webpacker directory `WEBPACKER_DIR` which has rails/webpacker's `package.json`. | ||
|
||
## Changing the Package | ||
### Setup with Yalc | ||
Use [`yalc`](https://github.com/wclr/yalc) unless you like yak shaving weird errors. | ||
1. In `WEBPACKER_DIR`, run `yalc publish` | ||
2. In `TEST_APP_DIR`, run `yarn link @rails/webpacker` | ||
|
||
## Update the Package Code | ||
1. Make some JS change in WEBPACKER_DIR | ||
2. Run `yalc push` and your changes will be pushed to your `TEST_APP_DIR`'s node_modules. | ||
3. You may need to run `yarn` in `TEST_APP_DIR` if you added or removed dependencies of rails/webpacker. | ||
|
||
## Updating the Ruby Code | ||
|
||
For the Ruby part, just change the gem reference `TEST_APP_DIR`, like: | ||
|
||
```ruby | ||
gem "webpacker", path: "../../forks/webpacker" | ||
``` |
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 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 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 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 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 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 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 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 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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { runningWebpackDevServer } = require('./env') | ||
const devServer = require('./dev_server') | ||
|
||
// This logic is tied to lib/webpacker/instance.rb | ||
const inliningCss = runningWebpackDevServer && devServer.hmr | ||
|
||
module.exports = inliningCss |
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 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 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 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