workflow: sfc playground
This commit is contained in:
34
packages/sfc-playground/vite.config.ts
Normal file
34
packages/sfc-playground/vite.config.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { defineConfig, Plugin } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue(), copyVuePlugin()],
|
||||
optimizeDeps: {
|
||||
exclude: ['consolidate']
|
||||
}
|
||||
})
|
||||
|
||||
function copyVuePlugin(): Plugin {
|
||||
return {
|
||||
name: 'copy-vue',
|
||||
generateBundle(_opts, bundle) {
|
||||
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 "yarn build vue -f esm-browser" first.`
|
||||
)
|
||||
}
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: 'vue.runtime.esm-browser.js',
|
||||
source: fs.readFileSync(filePath, 'utf-8')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user