Files
kreios/vite.config.js
T
carmine.savino 24df94cdc3 feat: integrate Draco compression for GLB models and implement encryption for secure loading
- Added DRACOLoader to starter.js for handling compressed GLB models.
- Created a createGltfLoader function to initialize GLTFLoader with DRACOLoader.
- Implemented dracoModels plugin in vite.config.js to compress GLB models during build.
- Introduced model_loader.js for loading encrypted GLB models with WebCrypto.
- Developed encryptModels plugin to encrypt GLB files, ensuring no clear models are exposed.
- Updated asset handling to remove uncompressed GLB files post-build.
2026-10-28 10:00:09 +01:00

59 lines
2.0 KiB
JavaScript

import { defineConfig } from 'vite';
import path from 'path';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { ViteMinifyPlugin } from 'vite-plugin-minify'
import dracoModels from './vite-plugins/draco-models.js';
// Cifratura dei modelli, pronta ma non attiva: vedi vite-plugins/encrypt-models.js.
// import encryptModels from './vite-plugins/encrypt-models.js';
export default defineConfig({
// Il configuratore è servito da Laravel sotto /configuratore/ (stessa origine dell'API):
// la build finisce direttamente in backoffice/public/configuratore.
base: '/configuratore/',
root: 'src',
// root è 'src', ma i file .env/.env.production vivono nella root del repo (accanto a build.sh).
envDir: path.resolve(__dirname),
build: {
outDir: path.resolve(__dirname, 'backoffice/public/configuratore'),
minify: true,
cssMinify: true,
emptyOutDir: true,
rollupOptions: {
input: {
main: path.resolve(__dirname, 'src/index.html')
}
},
},
plugins: [
viteStaticCopy({
targets: [
{
// I modelli 3D non vengono copiati così come sono: li comprime dracoModels.
src: ['assets/*', '!assets/models'],
dest: 'assets'
}
]
}),
dracoModels({
modelsDir: path.resolve(__dirname, 'src/assets/models'),
cacheDir: path.resolve(__dirname, 'node_modules/.cache/draco-models'),
}),
ViteMinifyPlugin({
minify: {
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true,
minifyURLs: true
}
})
],
resolve: {
alias: {
'three': path.resolve(__dirname, 'node_modules/three'),
'@': path.resolve(__dirname, 'src')
}
}
});