-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
132 lines (125 loc) · 3.89 KB
/
vite.config.ts
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
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import path from 'path';
import { fileURLToPath } from 'url';
import sveltePreprocess from 'svelte-preprocess'
import { RollupPluginObfuscatorOptions } from 'rollup-plugin-obfuscator';
import copy from 'rollup-plugin-copy';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = "index.html";
// Obfuscator options
const obfuscatorOptions: RollupPluginObfuscatorOptions["options"] = {
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: 0,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
/*log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: true,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayCallsTransform: false,
stringArrayEncoding: [],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false*/
};
// Your banner text
const banner = `/*!
* © ${new Date().getFullYear()} Lyteworx Automation Systems, LLC. and DigitalArsenal.io, Inc. - All Rights Reserved.
*
* No part of this software may be reproduced, distributed,
* or transmitted in any form or by any means, including photocopying, recording, or other
* electronic or mechanical methods, without the prior written permission.
* Reverse engineering, disassembly, or decompilation of this software is strictly prohibited.
*
*/`;
// https://vitejs.dev/config/
export default defineConfig({
base: '',
plugins: [svelte({
preprocess: sveltePreprocess(),
onwarn: (warning, handler) => {
if (warning.code.startsWith('a11y')) {
return;
}
// Handle all other warnings as usual
handler(warning);
},
}),
copy({
targets: [
{ src: './coi-serviceworker.js', dest: 'docs' }
],
hook: 'writeBundle' // Determines at which stage in the build the files should be copied
})
// viteCompression({ algorithm: "brotliCompress" })
// process.env.NODE_ENV === 'production' && Obfuscator({ global: true, options: obfuscatorOptions })
],
build: {
assetsInlineLimit: 0, // This ensures all assets are inlined
minify: "terser",
terserOptions: {
// Terser options to prevent stripping of debugger
compress: {
drop_debugger: false // Do not remove debugger statements
},
mangle: {
properties: { regex: /trackFromTo/g },
toplevel: true,
keep_classnames: true,
keep_fnames: true
}
},
emptyOutDir: false,
outDir: "docs",
rollupOptions: {
onwarn(warning, warn) {
// Check if the warning is a 'PLUGIN_WARNING' from 'vite:resolve'
if (warning.code === 'PLUGIN_WARNING' && warning.plugin === 'vite:resolve') {
// Check if the warning message is about externalizing modules for browser compatibility
if (warning.message && warning.message.includes('has been externalized for browser compatibility')) {
return; // This suppresses the specific warning
}
}
// Handle all other warnings as usual
warn(warning);
},
external: ['cesium'],
input: {
app,
},
output: {
banner
}
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
define: {
'window.CESIUM_BASE_URL': JSON.stringify("packages/orbpro/Build/Cesium"),
},
server: {
host: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization'
}
},
});