-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy path.fes.js
133 lines (131 loc) · 4.78 KB
/
.fes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* @Description:
* @Version: 1.668
* @Autor: 地虎降天龙
* @Date: 2023-10-16 10:53:09
* @LastEditors: 地虎降天龙
* @LastEditTime: 2025-04-17 18:19:25
*/
// import { resolve } from 'path';
import { join } from 'path'
import { defineBuildConfig } from '@fesjs/fes'
import { templateCompilerOptions } from '@tresjs/core'
// eslint-disable-next-line import/no-unresolved
import UnoCSS from 'unocss/vite'
// eslint-disable-next-line import/no-extraneous-dependencies
import glsl from 'vite-plugin-glsl'
import javascriptObfuscator from 'vite-plugin-javascript-obfuscator'
const timeStamp = new Date().getTime()
const combinedIsCustomElement = (tag) => tag.startsWith('iconify-icon') || templateCompilerOptions.template.compilerOptions.isCustomElement(tag)
export default defineBuildConfig({
mountElementId: 'tvt-app',
title: 'TvT.js',
publicPath: './', // './' 若在线部署用于生产环境 且 是使用qiankun微前端时,需要配置base为主应用地址 https://cos.icegl.cn/qiankun/tvt/
access: {
roles: {
admin: ['*'],
manager: ['/'],
},
},
layout: {
navigation: null,
},
enums: {
status: [
['0', '无效的'],
['1', '有效的'],
],
},
qiankun: {
micro: {
useDevMode: true,
},
},
//add by 地虎降天龙
viteVuePlugin: {
template: {
compilerOptions: {
isCustomElement: (tag) => combinedIsCustomElement(tag),
},
},
},
viteOption: {
plugins: [
UnoCSS({
/* options */
}),
glsl({
warnDuplicatedImports: false, // 禁用重复导入警告
}),
process.env.NODE_ENV === 'production' &&
javascriptObfuscator({
apply: 'build',
include: [/src\/.*\.js$/],
exclude: ['node_modules/**', '!node_modules/three/**', '!node_modules/@tresjs/core/**', '!node_modules/@tresjs/cientos/**',
/[\\/]@alienkitty[\\/]/,
],
options: {
optionsPreset: 'high-obfuscation', //'default',
debugProtection: true,
disableConsoleOutput: true,
controlFlowFlattening: false, // 🚀 关闭控制流混淆,避免 Babel 解析错误
identifierNamesGenerator: 'hexadecimal', // 仅修改变量名,不影响语法结构
reservedStrings: ['suspenseLayout.vue'],
compact: true,
stringArray: true,
stringArrayThreshold: 0.75,
stringArrayEncoding: ['rc4'],
splitStrings: false,
transformObjectKeys: false,
// ... [See more options](https://github.com/javascript-obfuscator/javascript-obfuscator)
},
}),
],
build: {
target: 'esnext', // 或者 'es2020' 以支持 BigInt
chunkSizeWarningLimit: 1000, // 单位为KB
rollupOptions: {
output: {
manualChunks(id) {
// 自定义拆分策略,例如将特定的第三方库拆分为单独的 chunk
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0]
}
},
format: 'es',
chunkFileNames: `js/[name].[hash]${timeStamp}.js`,
entryFileNames: `js/[name].[hash]${timeStamp}.js`,
assetFileNames: `[ext]/[name].[hash]${timeStamp}.[ext]`,
name: 'TvT.js',
},
},
sourcemap: false,
minify: process.env.NODE_ENV === 'production' ? 'terser' : false,
},
// 全局 css 注册
css: {
preprocessorOptions: {
scss: {
javascriptEnabled: true,
additionalData: `@import "src/plugins/goView/lib/scss/style.scss";`,
},
},
},
server: {
headers: {
'Access-Control-Allow-Origin': '*',
},
host: '0.0.0.0',
proxy: {
'/resource.cos': {
target: 'https://opensource.cdn.icegl.cn',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/resource.cos/, ''),
},
},
},
},
alias: { PLS: join(__dirname, './src/plugins') },
// { find: 'pls', replacement: resolve(__dirname, './src/plugins') },
// { '@': join(__dirname, '/src') }
})