build(vite): 优化代码构建并添加混淆
- 修改 .gitignore 文件,更新 lock 文件忽略规则 - 在 package.json 中添加新的脚本命令 - 更新 vite.config.ts,增加代码混淆和优化配置
This commit is contained in:
parent
5cc696b468
commit
a50af14222
2
.gitignore
vendored
2
.gitignore
vendored
@ -29,4 +29,4 @@ coverage
|
|||||||
|
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
||||||
*.lock*
|
*lock*
|
||||||
|
@ -8,9 +8,11 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
"d": "vite",
|
||||||
"build": "run-p type-check \"build-only {@}\" --",
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
|
"b": "vite build",
|
||||||
"type-check": "vue-tsc --build",
|
"type-check": "vue-tsc --build",
|
||||||
"format": "prettier --write src/"
|
"format": "prettier --write src/"
|
||||||
},
|
},
|
||||||
@ -29,6 +31,7 @@
|
|||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"pinia-plugin-persistedstate": "^4.5.0",
|
"pinia-plugin-persistedstate": "^4.5.0",
|
||||||
"sass-embedded": "^1.90.0",
|
"sass-embedded": "^1.90.0",
|
||||||
|
"vite-plugin-bundle-obfuscator": "^1.8.0",
|
||||||
"vue": "^3.5.18",
|
"vue": "^3.5.18",
|
||||||
"vue-router": "^4.5.1"
|
"vue-router": "^4.5.1"
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,9 @@ import { fileURLToPath, URL } from 'node:url';
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
import vueDevTools from 'vite-plugin-vue-devtools';
|
||||||
|
import Obfuscator from 'vite-plugin-bundle-obfuscator';
|
||||||
|
|
||||||
|
const date = new Date().getTime();
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
server: {
|
server: {
|
||||||
@ -12,7 +14,32 @@ export default defineConfig({
|
|||||||
'/api': 'http://localhost:7546',
|
'/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: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user