diff --git a/README.md b/README.md index ad81b4e9..6567edf5 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ Styles are not added on `import/require()`, but instead on call to `use`/`ref`. |Name|Type|Default|Description| |:--:|:--:|:-----:|:----------| +|**`hmr`**|`{Boolean}`|`true`|Enable/disable Hot Module Replacement (HMR), if disabled no HMR Code will be added (good for non local development/production)| |**`base`** |`{Number}`|`true`|Set module ID base (DLLPlugin)| |**`attrs`**|`{Object}`|`{}`|Add custom attrs to ``| |**`transform`** |`{Function}`|`false`|Transform/Conditionally load CSS by passing a transform/condition function| @@ -142,6 +143,21 @@ Styles are not added on `import/require()`, but instead on call to `use`/`ref`. |**`sourceMap`**|`{Boolean}`|`false`|Enable/Disable Sourcemaps| |**`convertToAbsoluteUrls`**|`{Boolean}`|`false`|Converts relative URLs to absolute urls, when source maps are enabled| +### `hmr` + +Enable/disable Hot Module Replacement (HMR), if disabled no HMR Code will be added. +This could be used for non local development and production. + +**webpack.config.js** +```js +{ + loader: 'style-loader' + options: { + hmr: false + } +} +``` + ### `base` This setting is primarily used as a workaround for [css clashes](https://github.com/webpack-contrib/style-loader/issues/163) when using one or more [DllPlugin](https://robertknight.github.io/posts/webpack-dll-plugins/)'s. `base` allows you to prevent either the *app*'s css (or *DllPlugin2*'s css) from overwriting *DllPlugin1*'s css by specifying a css module id base which is greater than the range used by *DllPlugin1* e.g.: diff --git a/index.js b/index.js index c4aee976..0179a4c0 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,24 @@ module.exports.pitch = function (request) { validateOptions(require('./options.json'), options, 'Style Loader') + options.hmr = typeof options.hmr === 'undefined' ? true : options.hmr; + + var hmrCode = [ + "// Hot Module Replacement", + "if(module.hot) {", + " // When the styles change, update the