Updated vite & ts config
This commit is contained in:
parent
86b488b492
commit
740a29688d
14
src/vite-env.d.ts
vendored
Normal file
14
src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
/// <reference types="vite-plugin-wasm/client" />
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noEmit": false,
|
"noEmit": false, // Ici on peut vouloir émettre des fichiers si nécessaire, ou garder true pour juste check
|
||||||
"outDir": "./dist",
|
"outDir": "./dist"
|
||||||
"module": "commonjs"
|
},
|
||||||
},
|
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.test.ts"]
|
||||||
"exclude": ["node_modules", "dist"]
|
}
|
||||||
}
|
|
||||||
@ -1,29 +1,42 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declaration": true,
|
|
||||||
"outDir": "./dist",
|
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"lib": ["DOM", "DOM.Iterable", "ESNext", "webworker"],
|
"useDefineForClassFields": true,
|
||||||
"types": ["vite/client", "node"],
|
|
||||||
"allowJs": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"esModuleInterop": false,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"strict": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Node",
|
"lib": ["ESNext", "DOM", "DOM.Iterable", "WebWorker"],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Mode Bundler (Vite) */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"experimentalDecorators": true,
|
"noEmit": true, /* Vite s'occupe de générer les fichiers, tsc fait juste la vérif */
|
||||||
"useDefineForClassFields": true,
|
|
||||||
"noEmit": true,
|
/* Qualité du code */
|
||||||
"jsx": "react-jsx",
|
"strict": true, /* Active toutes les vérifications strictes */
|
||||||
"baseUrl": "./",
|
"noUnusedLocals": false,
|
||||||
|
"noUnusedParameters": false,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"allowJs": true, /* Permet d'importer du JS si besoin (ex: legacy) */
|
||||||
|
|
||||||
|
/* Chemins (Alias) */
|
||||||
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"@/*": ["src/*"],
|
||||||
"~/*": ["src/*"]
|
"~/*": ["src/*"]
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/* Support des types Vite (client, workers, etc.) */
|
||||||
|
"types": ["vite/client"]
|
||||||
},
|
},
|
||||||
"include": ["src", "src/*/", "./vite.config.ts", "src/*.d.ts", "src/main.ts"],
|
"include": [
|
||||||
"exclude": ["node_modules"]
|
"src/**/*.ts",
|
||||||
|
"src/**/*.d.ts",
|
||||||
|
"src/**/*.tsx",
|
||||||
|
"src/**/*.vue",
|
||||||
|
"src/**/*.html", /* Important pour les imports ?raw */
|
||||||
|
"vite.config.ts"
|
||||||
|
],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
123
vite.config.ts
123
vite.config.ts
@ -1,85 +1,62 @@
|
|||||||
import { defineConfig } from 'vite';
|
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 wasm from 'vite-plugin-wasm';
|
||||||
import {createHtmlPlugin} from 'vite-plugin-html';
|
import { fileURLToPath, URL } from 'node:url';
|
||||||
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';
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
optimizeDeps: {
|
// Configuration du serveur de développement
|
||||||
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'],
|
|
||||||
},
|
|
||||||
server: {
|
server: {
|
||||||
fs: {
|
|
||||||
cachedChecks: false,
|
|
||||||
},
|
|
||||||
port: 3003,
|
port: 3003,
|
||||||
|
host: '0.0.0.0', // Permet l'accès depuis l'extérieur (Docker/Réseau)
|
||||||
proxy: {
|
proxy: {
|
||||||
|
// Proxy pour le stockage
|
||||||
'/storage': {
|
'/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,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
rewrite: (path) => path.replace(/^\/storage/, '/storage'),
|
},
|
||||||
configure: (proxy, _options) => {
|
// Proxy pour l'API BlindBit
|
||||||
proxy.on('error', (err, _req, _res) => {
|
'/blindbit': {
|
||||||
console.log('proxy error', err);
|
target: process.env.VITE_BLINDBITURL || 'https://dev2.4nkweb.com/blindbit',
|
||||||
});
|
changeOrigin: true,
|
||||||
proxy.on('proxyReq', (proxyReq, req, _res) => {
|
secure: false,
|
||||||
console.log('Sending Request:', req.method, req.url);
|
rewrite: (path) => path.replace(/^\/blindbit/, ''),
|
||||||
});
|
},
|
||||||
proxy.on('proxyRes', (proxyRes, req, _res) => {
|
},
|
||||||
console.log('Received Response:', proxyRes.statusCode, req.url);
|
},
|
||||||
});
|
|
||||||
}
|
// 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()],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user