Navigation Menu

Skip to content

Commit

Permalink
add option to show hmr error overlay, update docs (#1239)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Jacobs <brian.jacobs@natgeo.com>
  • Loading branch information
briantjacobs and brianjacobs-natgeo committed Oct 7, 2020
1 parent 75ad503 commit 5da777b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/docs/10-reference.md
Expand Up @@ -188,6 +188,8 @@ Options:
- The hostname where the browser tab will be open.
- **`devOptions.hmr`** | `boolean` | Default: `true`
- Toggles whether or not Snowpack dev server should have HMR enabled.
- **`devOptions.hmrErrorOverlay`** | `boolean` | Default: `true`
- When HMR is enabled, toggles whether or not a browser overlay should display javascript errors.
- **`devOptions.secure`** | `boolean`
- Toggles whether or not Snowpack dev server should use HTTPS with HTTP2 enabled.

Expand Down
5 changes: 4 additions & 1 deletion snowpack/src/build/build-import-proxy.ts
Expand Up @@ -75,7 +75,10 @@ export function wrapHtmlResponse({
});

if (hmr) {
const hmrScript = `<script type="module" src="${getMetaUrlPath('hmr-client.js', config)}"></script><script type="module" src="${getMetaUrlPath('hmr-error-overlay.js', config)}"></script>`;
let hmrScript = `<script type="module" src="${getMetaUrlPath('hmr-client.js', config)}"></script>`;
if (config.devOptions.hmrErrorOverlay) {
hmrScript += `<script type="module" src="${getMetaUrlPath('hmr-error-overlay.js', config)}"></script>`;
}
code = appendHtmlToHead(code, hmrScript);
}
return code;
Expand Down
2 changes: 2 additions & 0 deletions snowpack/src/config.ts
Expand Up @@ -50,6 +50,7 @@ const DEFAULT_CONFIG: Partial<SnowpackConfig> = {
fallback: 'index.html',
hmrDelay: 0,
hmrPort: 12321,
hmrErrorOverlay: true,
},
buildOptions: {
baseUrl: '/',
Expand Down Expand Up @@ -97,6 +98,7 @@ const configSchema = {
hmr: {type: 'boolean'},
hmrDelay: {type: 'number'},
hmrPort: {type: 'number'},
hmrErrorOverlay: {type: 'boolean'},
},
},
installOptions: {
Expand Down
1 change: 1 addition & 0 deletions snowpack/src/types/snowpack.ts
Expand Up @@ -138,6 +138,7 @@ export interface SnowpackConfig {
hmr?: boolean;
hmrDelay: number;
hmrPort: number;
hmrErrorOverlay: boolean;
};
installOptions: InstallOptions;
buildOptions: {
Expand Down

1 comment on commit 5da777b

@vercel
Copy link

@vercel vercel bot commented on 5da777b Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.