Skip to content

Commit

Permalink
style: format
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxch committed May 1, 2022
1 parent e5abd1b commit f253bf6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export function replaceSrc(placeholder: string, code: string) {

export function replaceImport(placeholder: string, code: string) {
return code.replace(/(System.import\()/g, `$1${placeholder}+`)
}
}
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function dynamicBase(options?: Options): Plugin {
configResolved(resolvedConfig) {
assetsDir = resolvedConfig.build.assetsDir
base = resolvedConfig.base
legacy = !!(resolvedConfig?.define?.['import.meta.env.LEGACY'])
legacy = !!resolvedConfig?.define?.['import.meta.env.LEGACY']
if (!base || base === '/') {
throw new Error(
'Please replace `config.base` in build with unique markup text, (e.g. /__dynamic_base__/)\n' +
Expand All @@ -33,7 +33,7 @@ export function dynamicBase(options?: Options): Plugin {
' (in your vite.config.ts/js file)'
)
}
Object.assign(baseOptions,{ assetsDir, base, legacy })
Object.assign(baseOptions, { assetsDir, base, legacy })
},
async generateBundle({ format }, bundle) {
if (format !== 'es' && format !== 'system') {
Expand All @@ -43,12 +43,12 @@ export function dynamicBase(options?: Options): Plugin {
Object.entries(bundle).map(async ([, chunk]) => {
if (chunk.type === 'chunk' && chunk.code.indexOf(base) > -1) {
chunk.code = await transformChunk(format, chunk.code, baseOptions)
} else if( chunk.type === 'asset' && typeof chunk.source === 'string'){
if(!chunk.fileName.endsWith('.html')){
} else if (chunk.type === 'asset' && typeof chunk.source === 'string') {
if (!chunk.fileName.endsWith('.html')) {
chunk.source = await transformAsset(chunk.source, baseOptions)
} else if(legacy && transformIndexHtml){
} else if (legacy && transformIndexHtml) {
chunk.source = await transformLegacyHtml(chunk.source, baseOptions)
}
}
}
})
)
Expand Down

0 comments on commit f253bf6

Please sign in to comment.