Skip to content

Commit

Permalink
chore: fix playground vite config
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Mar 15, 2023
1 parent 54a0391 commit 66c95df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
5 changes: 4 additions & 1 deletion packages/varlet-ui-playground/auto-imports.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Generated by 'unplugin-auto-import'
export {}
declare global {

const Dialog: typeof import('@varlet/ui')['Dialog']
const Locale: typeof import('@varlet/ui')['Locale']
const Snackbar: typeof import('@varlet/ui')['Snackbar']
const StyleProvider: typeof import('@varlet/ui')['StyleProvider']
}
14 changes: 4 additions & 10 deletions packages/varlet-ui-playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import fs from 'fs'
import components from 'unplugin-vue-components/vite'
import autoImport from 'unplugin-auto-import/vite'
import { resolve } from 'path'
import { VarletUIResolver } from 'unplugin-vue-components/resolvers'
import { defineConfig, Plugin } from 'vite'

const varletESMBundleFile = resolve(__dirname, '../varlet-ui/es/varlet.esm.js')
const varletTouchEmulatorFile = resolve(__dirname, '../varlet-touch-emulator/index.js')
const varletCSSFile = resolve(__dirname, '../varlet-ui/es/style.css')
const varletArea = resolve(__dirname, '../varlet-ui/json/area.json')

function copyVarletDependencies(): Plugin {
return {
name: 'copy-varlet-dependencies',

buildStart() {
fs.copyFileSync(varletESMBundleFile, resolve('public/varlet.esm.js'))
fs.copyFileSync(varletTouchEmulatorFile, resolve('public/varlet-touch-emulator.js'))
fs.copyFileSync(varletCSSFile, resolve('public/varlet.css'))
fs.writeFileSync(resolve('public/varlet-area.js'), `export default ${fs.readFileSync(varletArea)}`)
fs.copyFileSync('../varlet-ui/es/varlet.esm.js', './public/varlet.esm.js')
fs.copyFileSync('../varlet-touch-emulator/index.js', './public/varlet-touch-emulator.js')
fs.copyFileSync('../varlet-ui/es/style.css', './public/varlet.css')
fs.writeFileSync('./public/varlet-area.js', `export default ${fs.readFileSync('../varlet-ui/json/area.json')}`)
},
}
}
Expand Down

0 comments on commit 66c95df

Please sign in to comment.