Repository navigation
Expand file tree
/
Copy pathweb-dev-server.config.mjs
More file actions
51 lines (43 loc) · 1.73 KB
/
Copy pathweb-dev-server.config.mjs
File metadata and controls
51 lines (43 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import path from "path";
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
/** Use Hot Module replacement by adding --hmr to the start command */
const hmr = process.argv.includes('--hmr');
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
open: process.env.STORYBOOK ? '/' : true,
rootDir: process.env.STORYBOOK ? '/' : '../../',
watch: !hmr,
https: true,
dedupe: true,
/** Resolve bare module imports */
nodeResolve: {
exportConditions: ['browser', 'development'],
},
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
// esbuildTarget: 'auto'
/** Set appIndex to enable SPA routing */
// appIndex: 'demo/index.html',
appIndex: path.join(process.cwd(), "demo", "index.html"),
/**
* simple-fields loads some fields on demand from a base path that is
* node_modules/ once published but the repo root here, so the request
* arrives as /@haxtheweb/<package>/...; redirect it to elements/<package>/
* (a redirect, not a rewrite, so the module's relative imports resolve to
* the same URLs as everything else and nothing loads twice)
* https://github.com/haxtheweb/issues/issues/3208
*/
middleware: [
function haxtheWebMonorepoPackages(context, next) {
const match = context.url.match(/^\/@haxtheweb\/([^/?#]+)\/(.*)$/);
if (match) {
context.redirect(`/elements/${match[1]}/${match[2]}`);
return undefined;
}
return next();
},
],
plugins: [
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
],
// See documentation for all available options
});