@@ -2,11 +2,17 @@ import { defineConfig } from 'vite';
22import { VitePWA } from 'vite-plugin-pwa' ;
33import { viteStaticCopy } from 'vite-plugin-static-copy' ;
44import 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
1117export 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