@@ -139,7 +139,21 @@ const generateExamples = () => {
139
139
const appContent = createExampleApp ( component ) ;
140
140
writeFileSync ( join ( componentDir , 'App.tsx' ) , appContent ) ;
141
141
142
- // Create a simple index.html
142
+ // Create main.tsx entry point
143
+ const mainTsx = `import React from 'react';
144
+ import ReactDOM from 'react-dom/client';
145
+ import App from './App';
146
+ import 'ag-grid-community/styles/ag-grid.css';
147
+ import 'ag-grid-community/styles/ag-theme-quartz.css';
148
+
149
+ ReactDOM.createRoot(document.getElementById('root')!).render(
150
+ <React.StrictMode>
151
+ <App />
152
+ </React.StrictMode>
153
+ );` ;
154
+ writeFileSync ( join ( componentDir , 'main.tsx' ) , mainTsx ) ;
155
+
156
+ // Create index.html
143
157
const indexHtml = `<!DOCTYPE html>
144
158
<html lang="en">
145
159
<head>
@@ -149,11 +163,65 @@ const generateExamples = () => {
149
163
</head>
150
164
<body>
151
165
<div id="root"></div>
152
- <script type="module" src="/src/ main.tsx"></script>
166
+ <script type="module" src="/main.tsx"></script>
153
167
</body>
154
168
</html>` ;
155
169
156
170
writeFileSync ( join ( componentDir , 'index.html' ) , indexHtml ) ;
171
+
172
+ // Create vite.config.ts
173
+ const viteConfig = `import { defineConfig } from 'vite';
174
+ import react from '@vitejs/plugin-react';
175
+
176
+ export default defineConfig({
177
+ plugins: [react()],
178
+ });` ;
179
+
180
+ writeFileSync ( join ( componentDir , 'vite.config.ts' ) , viteConfig ) ;
181
+
182
+ // Create tsconfig.json
183
+ const tsConfig = {
184
+ compilerOptions : {
185
+ target : "ES2020" ,
186
+ useDefineForClassFields : true ,
187
+ lib : [ "ES2020" , "DOM" , "DOM.Iterable" ] ,
188
+ module : "ESNext" ,
189
+ skipLibCheck : true ,
190
+ moduleResolution : "bundler" ,
191
+ allowImportingTsExtensions : true ,
192
+ resolveJsonModule : true ,
193
+ isolatedModules : true ,
194
+ noEmit : true ,
195
+ jsx : "react-jsx" ,
196
+ strict : true ,
197
+ noUnusedLocals : true ,
198
+ noUnusedParameters : true ,
199
+ noFallthroughCasesInSwitch : true
200
+ } ,
201
+ include : [ "**/*.ts" , "**/*.tsx" ] ,
202
+ references : [ { path : "./tsconfig.node.json" } ]
203
+ } ;
204
+
205
+ writeFileSync ( join ( componentDir , 'tsconfig.json' ) , JSON . stringify ( tsConfig , null , 2 ) ) ;
206
+
207
+ // Create tsconfig.node.json
208
+ const tsConfigNode = {
209
+ compilerOptions : {
210
+ composite : true ,
211
+ skipLibCheck : true ,
212
+ module : "ESNext" ,
213
+ moduleResolution : "bundler" ,
214
+ allowSyntheticDefaultImports : true
215
+ } ,
216
+ include : [ "vite.config.ts" ]
217
+ } ;
218
+
219
+ writeFileSync ( join ( componentDir , 'tsconfig.node.json' ) , JSON . stringify ( tsConfigNode , null , 2 ) ) ;
220
+
221
+ // Copy package.json to each example
222
+ const examplePackageJson = JSON . parse ( readFileSync ( join ( sharedDir , 'package.json' ) , 'utf8' ) ) ;
223
+ examplePackageJson . name = `${ component . name . toLowerCase ( ) } -example` ;
224
+ writeFileSync ( join ( componentDir , 'package.json' ) , JSON . stringify ( examplePackageJson , null , 2 ) ) ;
157
225
} ) ;
158
226
159
227
// Create manifest
0 commit comments