Skip to content

Commit 9e966f5

Browse files
authored
chore: replace global.css with autoload.js in transform hook (#9276)
1 parent 182e3a0 commit 9e966f5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

web-dev-server.config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,20 @@ export function enforceThemePlugin(theme) {
4343
transform(context) {
4444
let { body } = context;
4545

46-
if (context.response.is('html') && (theme === 'base' || theme === 'ported-lumo')) {
47-
// Load the base theme
48-
body = body.replace('./common.js', './common-base.js');
46+
if (theme === 'legacy-lumo' && context.response.is('html', 'js')) {
47+
body = body.replace('vaadin-lumo-styles/global.css', 'vaadin-lumo-styles/test/autoload.js');
4948
}
5049

51-
if (context.response.is('html', 'js') && (theme === 'base' || theme === 'legacy-lumo')) {
52-
// Remove all CSS imports
50+
if (['base', 'legacy-lumo'].includes(theme) && context.response.is('html', 'js')) {
51+
// Remove all not transformed CSS imports
5352
body = body.replaceAll(/^.+vaadin-lumo-styles\/.+\.css.+$/gmu, '');
5453
}
5554

55+
if (['base', 'ported-lumo'].includes(theme) && context.response.is('html')) {
56+
// Load the base theme
57+
body = body.replace('./common.js', './common-base.js');
58+
}
59+
5660
return body;
5761
},
5862
transformImport({ source }) {
@@ -62,10 +66,6 @@ export function enforceThemePlugin(theme) {
6266
source = source.replace(/(.+)-core-styles\.js/u, '$1-base-styles.js');
6367
}
6468

65-
if (theme === 'legacy-lumo') {
66-
source = source.replace('vaadin-lumo-styles/global.css', 'vaadin-lumo-styles/test/autoload.js');
67-
}
68-
6969
return source;
7070
},
7171
};

0 commit comments

Comments
 (0)