mirror of
https://github.com/alex8088/electron-vite.git
synced 2026-04-29 17:28:15 +08:00
Compare commits
2 Commits
3df2516566
...
7feae64e7e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7feae64e7e | ||
|
|
deed6f5891 |
@ -143,7 +143,7 @@ const bytecodeModuleLoaderCode = [
|
||||
const bytecodeChunkExtensionRE = /.(jsc|cjsc)$/
|
||||
|
||||
export interface BytecodeOptions {
|
||||
chunkAlias?: string | string[]
|
||||
chunkAlias?: string | string[] | RegExp
|
||||
transformArrowFunctions?: boolean
|
||||
removeBundleJS?: boolean
|
||||
protectedStrings?: string[]
|
||||
@ -160,11 +160,13 @@ export function bytecodePlugin(options: BytecodeOptions = {}): Plugin | null {
|
||||
}
|
||||
|
||||
const { chunkAlias = [], transformArrowFunctions = true, removeBundleJS = true, protectedStrings = [] } = options
|
||||
const _chunkAlias = Array.isArray(chunkAlias) ? chunkAlias : [chunkAlias]
|
||||
const _chunkAlias = chunkAlias instanceof RegExp ? chunkAlias : Array.isArray(chunkAlias) ? chunkAlias : [chunkAlias]
|
||||
|
||||
const transformAllChunks = _chunkAlias.length === 0
|
||||
const isBytecodeChunk = (chunkName: string): boolean => {
|
||||
return transformAllChunks || _chunkAlias.some(alias => alias === chunkName)
|
||||
if (_chunkAlias instanceof RegExp) {
|
||||
return _chunkAlias.test(chunkName)
|
||||
}
|
||||
return _chunkAlias.length === 0 || _chunkAlias.some(alias => alias === chunkName)
|
||||
}
|
||||
|
||||
const plugins: babel.PluginItem[] = []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user