forked from NabuCasa/sl-web-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web-dev-server.config.mjs
35 lines (29 loc) · 967 Bytes
/
web-dev-server.config.mjs
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
// 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: '/',
watch: !hmr,
/** Resolve bare module imports */
nodeResolve: {
exportConditions: ['browser', 'development'],
},
mimeTypes: {
'**/*.py': 'application/javascript',
},
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
// esbuildTarget: 'auto'
/** Set appIndex to enable SPA routing */
appIndex: './index.html',
plugins: [
{
name: 'py-import-wrapper',
transform(context) {
if (context.request.url.endsWith(".py")) {
context.response.body = `const text = ${JSON.stringify(context.response.body)};\nexport default text;`
}
},
},
],
// See documentation for all available options
});