Skip to content

Commit

Permalink
workflow(sfc-playground): copy server-renderer browser build
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 25, 2022
1 parent ec2856c commit b50353a
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/sfc-playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,24 @@ function copyVuePlugin(): Plugin {
return {
name: 'copy-vue',
generateBundle() {
const filePath = path.resolve(
__dirname,
'../vue/dist/vue.runtime.esm-browser.js'
)
if (!fs.existsSync(filePath)) {
throw new Error(
`vue.runtime.esm-browser.js not built. ` +
`Run "nr build vue -f esm-browser" first.`
)
const copyFile = (file: string) => {
const filePath = path.resolve(__dirname, file)
const basename = path.basename(file)
if (!fs.existsSync(filePath)) {
throw new Error(
`${basename} not built. ` +
`Run "nr build vue -f esm-browser" first.`
)
}
this.emitFile({
type: 'asset',
fileName: basename,
source: fs.readFileSync(filePath, 'utf-8')
})
}
this.emitFile({
type: 'asset',
fileName: 'vue.runtime.esm-browser.js',
source: fs.readFileSync(filePath, 'utf-8')
})

copyFile(`../vue/dist/vue.runtime.esm-browser.js`)
copyFile(`../server-renderer/dist/server-renderer.esm-browser.js`)
}
}
}

0 comments on commit b50353a

Please sign in to comment.