-
Notifications
You must be signed in to change notification settings - Fork 0
/
web-dev-server.config.js
33 lines (31 loc) · 1005 Bytes
/
web-dev-server.config.js
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
// @ts-check
import { pfeDevServerConfig } from '@patternfly/pfe-tools/dev-server/config.js';
export const litcssOptions = {
include: (/** @type{string[]}*/(/** @type{unknown}*/([
/elements\/hack-[\w-]+\/[\w-]+\.css$/,
/lib\/.*\.css$/,
]))),
exclude: /lightdom/,
};
export default pfeDevServerConfig({
litcssOptions,
tsconfig: 'tsconfig.json',
middleware: [
/** redirect requests for lightdom css to /elements */
function(ctx, next) {
const match = ctx.path.match(/^\/components\/(?<slug>[-\w]+)\/(?<path>.*)\.css$/);
if (match) {
const { slug, path } = /** @type{{ slug: string; path: string }} */ (match.groups);
ctx.redirect(`/elements/hack-${slug}/${path}.css`);
}
return next();
},
/** redirect requests for /assets/prism.css css to /docs/assets/prism.css */
function(ctx, next) {
if (ctx.path === '/assets/prism.css') {
ctx.redirect('/docs/assets/prism.css');
}
return next();
}
]
});