diff --git a/.gitignore b/.gitignore index ce8c118..d419b9f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,4 @@ coverage *.tsbuildinfo -*.lock* +*lock* diff --git a/package.json b/package.json index 574c6d5..4461769 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,11 @@ }, "scripts": { "dev": "vite", + "d": "vite", "build": "run-p type-check \"build-only {@}\" --", "preview": "vite preview", "build-only": "vite build", + "b": "vite build", "type-check": "vue-tsc --build", "format": "prettier --write src/" }, @@ -29,6 +31,7 @@ "pinia": "^3.0.3", "pinia-plugin-persistedstate": "^4.5.0", "sass-embedded": "^1.90.0", + "vite-plugin-bundle-obfuscator": "^1.8.0", "vue": "^3.5.18", "vue-router": "^4.5.1" }, diff --git a/vite.config.ts b/vite.config.ts index 848fdf3..70e61b3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,7 +3,9 @@ import { fileURLToPath, URL } from 'node:url'; import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import vueDevTools from 'vite-plugin-vue-devtools'; +import Obfuscator from 'vite-plugin-bundle-obfuscator'; +const date = new Date().getTime(); // https://vite.dev/config/ export default defineConfig({ server: { @@ -12,7 +14,32 @@ export default defineConfig({ '/api': 'http://localhost:7546', }, }, - plugins: [vue(), vueDevTools()], + + build: { + rollupOptions: { + output: { + chunkFileNames: `assets/data/js/[hash].${date}.js`, + entryFileNames: `assets/data/js/[hash].${date}.js`, + assetFileNames: `assets/data/[ext]/[hash].${date}.[ext]`, + }, + }, + terserOptions: { + compress: { + drop_console: true, + drop_debugger: true, + }, + }, + }, + plugins: [ + vue(), + vueDevTools(), + Obfuscator({ + enable: true, + log: true, + autoExcludeNodeModules: true, + threadPool: true, + }), + ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)),