@@ -3,6 +3,7 @@ import {Config, ViteConfigFn} from "./type";
3
3
import {
4
4
createWorkerTask ,
5
5
formatTime ,
6
+ getChunkName ,
6
7
getManualChunks ,
7
8
getThreadPoolSize ,
8
9
getValidBundleList ,
@@ -14,7 +15,7 @@ import {
14
15
obfuscateBundle
15
16
} from "./utils" ;
16
17
import { isArray , isFunction , isObject } from "./utils/is" ;
17
- import { defaultConfig , LOG_COLOR , NODE_MODULES } from "./utils/constants" ;
18
+ import { defaultConfig , LOG_COLOR , NODE_MODULES , VENDOR_MODULES } from "./utils/constants" ;
18
19
19
20
export default function viteBundleObfuscator ( config ?: Partial < Config > ) : PluginOption {
20
21
const finalConfig = { ...defaultConfig , ...config } ;
@@ -29,20 +30,13 @@ export default function viteBundleObfuscator(config?: Partial<Config>): PluginOp
29
30
30
31
const manualChunks = [ ...getManualChunks ( finalConfig ) ] ;
31
32
32
- const addChunks2Excludes = ( ) : void => {
33
- finalConfig . excludes . push ( NODE_MODULES , ...manualChunks . map ( modifyChunkName ) ) ;
33
+ const addChunks2Excludes = ( ) => {
34
+ finalConfig . excludes . push ( VENDOR_MODULES , ...manualChunks . map ( modifyChunkName ) ) ;
34
35
}
35
36
36
- const getChunkName = ( id : string ) : string => {
37
- for ( const chunkName of manualChunks ) {
38
- if ( id . includes ( chunkName ) ) return modifyChunkName ( chunkName ) ;
39
- }
40
-
41
- return NODE_MODULES ;
42
- } ;
43
-
44
- const defaultManualChunks = ( id : string ) : string | undefined => {
45
- if ( id . includes ( 'node_modules' ) ) return getChunkName ( id ) ;
37
+ const defaultManualChunks = ( id : string ) => {
38
+ if ( id . includes ( NODE_MODULES ) ) return getChunkName ( id , manualChunks ) ;
39
+ return undefined ;
46
40
} ;
47
41
48
42
if ( ! output ) {
0 commit comments