diff --git a/docs/webpack-dev-server.md b/docs/webpack-dev-server.md index 0bac0f287..7d8db6507 100644 --- a/docs/webpack-dev-server.md +++ b/docs/webpack-dev-server.md @@ -17,7 +17,20 @@ Now if you refresh your Rails view everything should work as expected. ## HOT module replacement Webpacker out-of-the-box supports HMR with `webpack-dev-server` and -you can toggle it by setting `dev_server/hmr` option inside `webpacker.yml`. +you can toggle it by setting options in `config/webpacker.yml`: + +```yaml +development: + # ... + extract_css: false + # ... + dev_server: + # ... + hmr: true + inline: true + # ... +``` +`dev_server/hmr` option inside `webpacker.yml`. Checkout this guide for more information: diff --git a/lib/install/config/webpacker.yml b/lib/install/config/webpacker.yml index a6b146566..efe7ded9f 100644 --- a/lib/install/config/webpacker.yml +++ b/lib/install/config/webpacker.yml @@ -16,7 +16,7 @@ default: &default cache_manifest: false # Extract and emit a css file - extract_css: false + extract_css: true static_assets_extensions: - .jpg @@ -51,6 +51,9 @@ development: <<: *default compile: true + # Set to false if using HMR for CSS + extract_css: true + # Reference: https://webpack.js.org/configuration/dev-server/ dev_server: https: false @@ -85,8 +88,5 @@ production: # Production depends on precompilation of packs prior to booting for performance. compile: false - # Extract and emit a css file - extract_css: true - # Cache manifest.json for performance cache_manifest: true diff --git a/lib/install/javascript/packs/application.css b/lib/install/javascript/packs/application.css new file mode 100644 index 000000000..6f47c31e6 --- /dev/null +++ b/lib/install/javascript/packs/application.css @@ -0,0 +1,6 @@ +/* +Any CSS added to this file or imported from this file, e.g. `@import '../stylesheets/my-css.css'`, +will be included in the "application" pack. Any CSS imported from application.js or as part of the +application.js dependency graph, e.g. `import '../stylesheets/my-css.css'` will also be included +in the "application" pack. +*/