diff --git a/README.md b/README.md index 44a80a31..dd5ee040 100644 --- a/README.md +++ b/README.md @@ -145,9 +145,12 @@ This should create an additional `styles.css.map` file. ### Hot Reload -Hot reloading is turned off by default, you can turn it on using the `hotReload` option as shown below: +This loader supports component-level HMR via the community supported [svelte-hmr](https://github.com/rixo/svelte-hmr) package. This package serves as a testbed and early access for Svelte HMR, while we figure out how to best include HMR support in the compiler itself (which is tricky to do without unfairly favoring any particular dev tooling). Feedback, suggestion, or help to move HMR forward is welcomed at [svelte-hmr](https://github.com/rixo/svelte-hmr/issues) (for now). + +Configure inside your `webpack.config.js`: ```javascript +module.exports = { ... module: { rules: [ @@ -158,68 +161,74 @@ Hot reloading is turned off by default, you can turn it on using the `hotReload` use: { loader: 'svelte-loader', options: { - hotReload: true + // NOTE Svelte's dev mode MUST be enabled for HMR to work + // -- in a real config, you'd probably set it to false for prod build, + // based on a env variable or so + dev: true, + + // NOTE emitCss: true is currently not supported with HMR + // Enable it for production to output separate css file + emitCss: false, + // Enable HMR only for dev mode + hotReload: true, // Default: false + // Extra HMR options + hotOptions: { + // Prevent preserving local component state + noPreserveState: false, + + // If this string appears anywhere in your component's code, then local + // state won't be preserved, even when noPreserveState is false + noPreserveStateKey: '@!hmr', + + // Prevent doing a full reload on next HMR update after fatal error + noReload: false, + + // Try to recover after runtime errors in component init + optimistic: false, + + // --- Advanced --- + + // Prevent adding an HMR accept handler to components with + // accessors option to true, or to components with named exports + // (from