Skip to content

Commit

Permalink
perf(nuxt): reduce multiple calls to dirname (#22800)
Browse files Browse the repository at this point in the history
  • Loading branch information
djixadin committed Aug 25, 2023
1 parent f06ee59 commit a70904f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vite/src/plugins/ssr-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down

0 comments on commit a70904f

Please sign in to comment.