Skip to content

Commit d5c6c19

Browse files
fix(tools): dev server config for lightdom css (#2488)
* fix(tools): lightdom css support in dev server * chore(tools): add changeset * fix(tools): consolidate rule * fix(tools): remove extra middleware and litcssOptions config * docs: Update .changeset/strong-donkeys-care.md --------- Co-authored-by: Benny Powers <[email protected]>
1 parent ded75eb commit d5c6c19

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.changeset/strong-donkeys-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@patternfly/pfe-tools": patch
3+
---
4+
5+
**Dev Server**: fixes `*-lightdom.css` support in config

tools/pfe-tools/dev-server/config.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,18 @@ function pfeDevServerPlugin(options: PfeDevServerInternalConfig): Plugin {
116116
const { element, fileName } = ctx.params;
117117
ctx.redirect(`/${elementsDir}/${element}/${fileName}.ts`);
118118
})
119+
// Redirect `components/pf-jazz-hands|jazz-hands/demo/*-lightdom.css` to `components/pf-jazz-hands/*-lightdom.css`
119120
// Redirect `components/jazz-hands/demo/*.js|css` to `components/pf-jazz-hands/demo/*.js|css`
120121
.get(`/${componentSubpath}/:element/demo/:demoSubDir?/:fileName.:ext`, async (ctx, next) => {
121122
const { element, fileName, ext } = ctx.params;
123+
let prefixedElement = element;
122124
if (!element.includes(tagPrefix)) {
123-
ctx.redirect(`/${elementsDir}/${tagPrefix}-${element}/demo/${fileName}.${ext}`);
125+
prefixedElement = `${tagPrefix}-${element}`;
126+
}
127+
if (fileName.includes('-lightdom') && ext === 'css') {
128+
ctx.redirect(`/${elementsDir}/${prefixedElement}/${fileName}.${ext}`);
129+
} else if (!element.includes(tagPrefix)) {
130+
ctx.redirect(`/${elementsDir}/${prefixedElement}/demo/${fileName}.${ext}`);
124131
} else {
125132
return next();
126133
}
@@ -152,7 +159,12 @@ function normalizeOptions(options?: PfeDevServerConfigOptions): PfeDevServerInte
152159
config.site = { ...config.site, ...options?.site ?? {} };
153160
config.loadDemo ??= true;
154161
config.watchFiles ??= '{elements,core}/**/*.{css,html}';
155-
config.litcssOptions ??= { include: /\.css$/, exclude: /((fonts|demo)|(demo\/.*))\.css$/ };
162+
163+
config.litcssOptions ??= {
164+
include: /\.css$/,
165+
exclude: /(((fonts|demo)|(demo\/.*))\.css$)|(.*(-lightdom.css$))/
166+
};
167+
156168
return config as PfeDevServerInternalConfig;
157169
}
158170

0 commit comments

Comments
 (0)