-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathweb-dev-server.config.mjs
57 lines (45 loc) · 1.7 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
/** Use Hot Module replacement by adding --hmr to the start command */
function cacheMiddleware() {
console.log('Cache middleware enabled');
return async (context, next) => {
await next();
if (context.url.match(/\.(js|css|png|jpg|jpeg|gif|ico)$/)) {
context.response.set('Cache-Control', 'public, max-age=31536000');
}
};
}
const hmr = process.argv.includes('--hmr');
const cacheEnabled = process.argv.includes('--cache');
const middlewares = [
proxy('/api/', {
target: 'https://www6ghml.senado.leg.br/',
rewrite: path => path.replace(/^\/api/, '/editor-emendas/api'),
logs: true,
changeOrigin: true
}),
];
cacheEnabled && middlewares.push(cacheMiddleware());
import proxy from 'koa-proxies';
//import httpsProxyAgent from 'https-proxy-agent';
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
nodeResolve: true,
open: '/demo',
// open: '/prod/index.html',
watch: !hmr,
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
// esbuildTarget: 'auto'
/** Set appIndex to enable SPA routing */
// appIndex: 'demo/index.html',
/** Confgure bare import resolve plugin */
// nodeResolve: {
// exportConditions: ['browser', 'development']
// },
// TODO Não está funcionando na rede do SF por não estar utilizando o proxy da rede no acesso à url externa
middleware: middlewares,
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
});