@@ -21,8 +21,7 @@ npm install -D @vitejs/plugin-react vite typescript @types/react @types/react-do
21
21
22
22
### Install SB1/FFE design system components
23
23
``` bash
24
- npm install @sb1/ffe-core @sb1/ffe-core-react @sb1/ffe-buttons @sb1/ffe-buttons-react @sb1/ffe-form @sb1/ffe-form-react @sb1/ffe-grid @sb1/ffe-grid-react
25
- ```
24
+ npm install @sb1/ffe-account-selector-react @sb1/ffe-buttons-react @sb1/ffe-cards-react @sb1/ffe-chart-donut-react @sb1/ffe-collapse-react @sb1/ffe-context-message-react @sb1/ffe-core-react @sb1/ffe-datepicker-react @sb1/ffe-dropdown-react @sb1/ffe-feedback-react @sb1/ffe-file-upload-react @sb1/ffe-form-react @sb1/ffe-grid-react @sb1/ffe-icons-react @sb1/ffe-lists-react @sb1/ffe-message-box-react @sb1/ffe-messages-react @sb1/ffe-modals-react @sb1/ffe-chips-react @sb1/ffe-pagination-react @sb1/ffe-searchable-dropdown-react @sb1/ffe-spinner-react @sb1/ffe-symbols-react @sb1/ffe-system-message-react @sb1/ffe-tables-react @sb1/ffe-tabs-react` ` `
26
25
27
26
# ## Install LESS support
28
27
` ` ` bash
@@ -114,6 +113,92 @@ npm pkg set scripts.build="tsc && vite build"
114
113
npm pkg set scripts.preview=" vite preview"
115
114
```
116
115
116
+ ### Vite config file with .less imports automated
117
+
118
+ ``` ts
119
+ // vite.config.ts
120
+ import { defineConfig } from ' vite' ;
121
+ import react from ' @vitejs/plugin-react' ;
122
+ import { resolve } from ' path' ;
123
+ import { glob } from ' glob' ;
124
+
125
+ // Function to collect all FFE LESS imports
126
+ async function collectFfeImports() {
127
+ try {
128
+ const nodeModulesPath = resolve (__dirname , ' node_modules/@sb1' );
129
+ console .log (' Searching for LESS files in:' , nodeModulesPath );
130
+
131
+ const lessFiles = await glob (' **/less/*.less' , {
132
+ cwd: nodeModulesPath ,
133
+ ignore: [' **/node_modules/**' ],
134
+ absolute: false ,
135
+ });
136
+
137
+ console .log (' Found LESS files:' , lessFiles );
138
+
139
+ // Start with core colors as it's a dependency for other components
140
+ const imports = [' @import "@sb1/ffe-core/less/colors";' ];
141
+
142
+ // Add all other FFE imports, excluding core colors
143
+ for (const file of lessFiles ) {
144
+ // Skip if it's colors.less since we already imported it
145
+ if (! file .includes (' ffe-core/less/colors.less' )) {
146
+ // Remove the .less extension for the import
147
+ const importPath = file .replace (' .less' , ' ' );
148
+ imports .push (` @import "@sb1/${importPath }"; ` );
149
+ }
150
+ }
151
+
152
+ const finalImports = imports .join (' \n ' );
153
+ console .log (' Generated imports:' , finalImports );
154
+
155
+ return finalImports ;
156
+ } catch (error ) {
157
+ console .error (' Error collecting FFE imports:' , error );
158
+ // Return just the core colors import as fallback
159
+ return ' @import "@sb1/ffe-core/less/colors";' ;
160
+ }
161
+ }
162
+
163
+ export default defineConfig (async () => ({
164
+ plugins: [react ()],
165
+ server: {
166
+ port: 3000 ,
167
+ open: true ,
168
+ },
169
+ css: {
170
+ preprocessorOptions: {
171
+ less: {
172
+ javascriptEnabled: true ,
173
+ math: ' always' ,
174
+ additionalData: await collectFfeImports (),
175
+ },
176
+ },
177
+ },
178
+ resolve: {
179
+ alias: {
180
+ ' @' : resolve (__dirname , ' ./src' ),
181
+ ' @components' : resolve (__dirname , ' ./src/components' ),
182
+ ' @styles' : resolve (__dirname , ' ./src/styles' ),
183
+ },
184
+ },
185
+ build: {
186
+ outDir: ' dist' ,
187
+ sourcemap: true ,
188
+ rollupOptions: {
189
+ output: {
190
+ manualChunks: {
191
+ ' react-vendor' : [' react' , ' react-dom' ],
192
+ ' sb1-core' : [' @sb1/ffe-core' , ' @sb1/ffe-core-react' ],
193
+ },
194
+ },
195
+ },
196
+ },
197
+ }));
198
+
199
+ ```
200
+
201
+
117
202
### Start development server
118
203
``` bash
119
204
npm run dev
0 commit comments