Scripts/resources/[ps]/ps-objectspawner/svelte-source/vite.config.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-12-29 20:28:24 +00:00
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import WindiCSS from 'vite-plugin-windicss'
import { minify } from "html-minifier";
const minifyHtml = () => {
return {
name: 'html-transform',
transformIndexHtml(html) {
return minify(html, {
collapseWhitespace: true,
});
},
};
};
export default defineConfig(({ mode }) => {
const isProduction = mode === 'production';
return {
plugins: [WindiCSS(), svelte(),
isProduction && minifyHtml(),
// isProduction && viteCompression({algorithm: "brotliCompress", ext:".bz"})
],
base: './', // fivem nui needs to have local dir reference
build: {
minify: isProduction,
emptyOutDir: true,
outDir: '../html',
assetsDir: './',
rollupOptions: {
output: {
// By not having hashes in the name, you don't have to update the manifest, yay!
entryFileNames: `[name].js`,
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`
}
}
},
};
});