Skip to content

Commit 2879050

Browse files
Hristo HristovHristo Hristov
authored andcommitted
fix(wc): add all themes that exist on build
1 parent 4fa2192 commit 2879050

File tree

1 file changed

+14
-7
lines changed
  • packages/cli/templates/webcomponents/igc-ts/projects/_base/files

1 file changed

+14
-7
lines changed

packages/cli/templates/webcomponents/igc-ts/projects/_base/files/vite.config.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import { defineConfig } from 'vite';
22
import { VitePWA } from 'vite-plugin-pwa';
33
import { viteStaticCopy } from 'vite-plugin-static-copy';
44
import fs from 'fs';
5+
import path from 'path';
56

6-
const gridMaterialCssPath = [
7-
'node_modules/igniteui-webcomponents-grids/grids/themes/light/material.css',
8-
'node_modules/@infragistics/igniteui-webcomponents-grids/grids/themes/light/material.css'
9-
].find(fs.existsSync) || null;
7+
const themeColors = ["light", "dark"];
8+
const themeTypes = ["material", "bootstrap", "indigo", "fluent"];
9+
const basePaths = [
10+
"node_modules/igniteui-webcomponents-grids/grids/themes",
11+
"node_modules/@infragistics/igniteui-webcomponents-grids/grids/themes"
12+
];
13+
const themeFiles = themeColors.flatMap(color =>
14+
themeTypes.flatMap(theme => basePaths.map(basePath => `${basePath}/${color}/${theme}.css`))
15+
).filter(fs.existsSync);
1016

1117
export default defineConfig({
1218
build: {
@@ -31,8 +37,9 @@ export default defineConfig({
3137
name: 'replace-grid-material-css-path',
3238
apply: 'build',
3339
transform(code, id) {
34-
if (gridMaterialCssPath && id.endsWith('.js')) {
35-
return code.replace(gridMaterialCssPath, '../../material.css');
40+
if (id.endsWith('.js')) {
41+
themeFiles.forEach(t => { code = code.replaceAll(t, `../../${path.basename(t)}`); });
42+
return code;
3643
}
3744
}
3845
},
@@ -41,7 +48,7 @@ export default defineConfig({
4148
targets: [
4249
{ src: 'src/assets', dest: 'src' },
4350
{ src: 'ig-theme.css', dest: '' },
44-
...(gridMaterialCssPath ? [{ src: gridMaterialCssPath, dest: '' }] : [])
51+
...themeFiles.map(themePath => ({ src: themePath, dest: '' }))
4552
],
4653
silent: true,
4754
}),

0 commit comments

Comments
 (0)