diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..b52b23e --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1,14 @@ +/// +/// + +// Permet d'importer des fichiers HTML comme des chaînes de caractères +declare module '*.html?raw' { + const content: string; + export default content; +} + +// Permet d'importer des fichiers CSS comme des chaînes de caractères (inline) +declare module '*.css?inline' { + const content: string; + export default content; +} diff --git a/tsconfig.build.json b/tsconfig.build.json index 0cda733..4161e97 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,9 +1,8 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": false, - "outDir": "./dist", - "module": "commonjs" - }, - "exclude": ["node_modules", "dist"] - } \ No newline at end of file + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, // Ici on peut vouloir émettre des fichiers si nécessaire, ou garder true pour juste check + "outDir": "./dist" + }, + "exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.test.ts"] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 7e4092b..bcada47 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,42 @@ { "compilerOptions": { - "declaration": true, - "outDir": "./dist", "target": "ESNext", - "lib": ["DOM", "DOM.Iterable", "ESNext", "webworker"], - "types": ["vite/client", "node"], - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": false, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, + "useDefineForClassFields": true, "module": "ESNext", - "moduleResolution": "Node", + "lib": ["ESNext", "DOM", "DOM.Iterable", "WebWorker"], + "skipLibCheck": true, + + /* Mode Bundler (Vite) */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, - "experimentalDecorators": true, - "useDefineForClassFields": true, - "noEmit": true, - "jsx": "react-jsx", - "baseUrl": "./", + "noEmit": true, /* Vite s'occupe de générer les fichiers, tsc fait juste la vérif */ + + /* Qualité du code */ + "strict": true, /* Active toutes les vérifications strictes */ + "noUnusedLocals": false, + "noUnusedParameters": false, + "noFallthroughCasesInSwitch": true, + "allowJs": true, /* Permet d'importer du JS si besoin (ex: legacy) */ + + /* Chemins (Alias) */ + "baseUrl": ".", "paths": { + "@/*": ["src/*"], "~/*": ["src/*"] - } + }, + + /* Support des types Vite (client, workers, etc.) */ + "types": ["vite/client"] }, - "include": ["src", "src/*/", "./vite.config.ts", "src/*.d.ts", "src/main.ts"], - "exclude": ["node_modules"] + "include": [ + "src/**/*.ts", + "src/**/*.d.ts", + "src/**/*.tsx", + "src/**/*.vue", + "src/**/*.html", /* Important pour les imports ?raw */ + "vite.config.ts" + ], + "exclude": ["node_modules", "dist"] } \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index fb3978a..c33820a 100755 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,85 +1,62 @@ import { defineConfig } from 'vite'; -import vue from '@vitejs/plugin-vue'; // or react from '@vitejs/plugin-react' if using React import wasm from 'vite-plugin-wasm'; -import {createHtmlPlugin} from 'vite-plugin-html'; -import typescript from "@rollup/plugin-typescript"; -import fs from 'fs' -import path from 'path' -import { fileURLToPath } from 'url'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -// import pluginTerminal from 'vite-plugin-terminal'; +import { fileURLToPath, URL } from 'node:url'; export default defineConfig({ - optimizeDeps: { - include: ['qrcode'] - }, - plugins: [ - vue(), // or react() if using React - wasm(), - createHtmlPlugin({ - minify: true, - template: 'index.html', - }), - typescript({ - sourceMap: false, - declaration: true, - declarationDir: "dist/types", - rootDir: "src", - outDir: "dist", - }), - // pluginTerminal({ - // console: 'terminal', - // output: ['terminal', 'console'] - // }) - ], - build: { - outDir: 'dist', - target: 'esnext', - minify: false, - rollupOptions: { - input: './src/index.ts', - output: { - entryFileNames: 'index.js', - }, - }, - lib: { - entry: path.resolve(__dirname, 'src/router.ts'), - name: 'ihm-service', - formats: ['es'], - fileName: (format) => `ihm-service.${format}.js`, - }, - }, - resolve: { - alias: { - '@': '/src', - }, - extensions: ['.ts', '.tsx', '.js'], - }, + // Configuration du serveur de développement server: { - fs: { - cachedChecks: false, - }, port: 3003, + host: '0.0.0.0', // Permet l'accès depuis l'extérieur (Docker/Réseau) proxy: { + // Proxy pour le stockage '/storage': { - target: 'https://dev3.4nkweb.com', + target: process.env.VITE_STORAGEURL || 'https://dev2.4nkweb.com', + changeOrigin: true, + secure: false, // Accepte les certificats auto-signés si besoin + rewrite: (path) => path.replace(/^\/storage/, '/storage'), + }, + // Proxy pour les websockets (si besoin de contourner CORS ou SSL) + '/ws': { + target: process.env.VITE_BOOTSTRAPURL?.replace('ws', 'http') || 'https://dev2.4nkweb.com', + ws: true, changeOrigin: true, secure: false, - rewrite: (path) => path.replace(/^\/storage/, '/storage'), - configure: (proxy, _options) => { - proxy.on('error', (err, _req, _res) => { - console.log('proxy error', err); - }); - proxy.on('proxyReq', (proxyReq, req, _res) => { - console.log('Sending Request:', req.method, req.url); - }); - proxy.on('proxyRes', (proxyRes, req, _res) => { - console.log('Received Response:', proxyRes.statusCode, req.url); - }); - } - } - } + }, + // Proxy pour l'API BlindBit + '/blindbit': { + target: process.env.VITE_BLINDBITURL || 'https://dev2.4nkweb.com/blindbit', + changeOrigin: true, + secure: false, + rewrite: (path) => path.replace(/^\/blindbit/, ''), + }, + }, + }, + + // Plugins essentiels + plugins: [ + wasm(), // Indispensable pour ton SDK Rust + ], + + // Alias pour les imports (ex: import ... from '@/services/...') + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)), + '~': fileURLToPath(new URL('./src', import.meta.url)), // Rétro-compatibilité avec tes anciens imports + }, + }, + + // Configuration du Build + build: { + target: 'esnext', // Nécessaire pour le "Top Level Await" souvent utilisé avec WASM + outDir: 'dist', + assetsDir: 'assets', + emptyOutDir: true, // Vide le dossier dist avant chaque build + // On retire la config "lib" car c'est maintenant une App autonome + }, + + // Configuration spécifique pour les Workers (Database) + worker: { + format: 'es', + plugins: () => [wasm()], }, });