perf(nuxt): reduce multiple calls to dirname (#22800)

This commit is contained in:
Mihailo Bursac 2023-08-25 09:50:46 +02:00 committed by GitHub
parent f06ee59d4a
commit a70904fd8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,11 +75,13 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin {
source: ''
})
const baseDir = dirname(base)
emitted[file] = this.emitFile({
type: 'asset',
name: `${filename(file)}-styles.mjs`,
source: [
...files.map((css, i) => `import style_${i} from './${relative(dirname(base), this.getFileName(css))}';`),
...files.map((css, i) => `import style_${i} from './${relative(baseDir, this.getFileName(css))}';`),
`export default [${files.map((_, i) => `style_${i}`).join(', ')}]`
].join('\n')
})