Skip to content

Commit

Permalink
revert: fix workflow
Browse files Browse the repository at this point in the history
This reverts commit b6da6e8.
  • Loading branch information
haoziqaq committed Mar 15, 2023
1 parent b6da6e8 commit cc4554c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
25 changes: 24 additions & 1 deletion packages/varlet-ui-playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
import fs from 'fs'
import components from 'unplugin-vue-components/vite'
import autoImport from 'unplugin-auto-import/vite'
import { VarletUIResolver } from 'unplugin-vue-components/resolvers'
import { defineConfig } from 'vite'
import { defineConfig, Plugin } from 'vite'
import { fileURLToPath, URL } from 'node:url'

function toPath(path: string) {
return fileURLToPath(new URL(path, import.meta.url))
}

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

buildStart() {
fs.copyFileSync(toPath('../varlet-ui/es/varlet.esm.js'), toPath('./public/varlet.esm.js'))
fs.copyFileSync(toPath('../varlet-touch-emulator/index.js'), toPath('./public/varlet-touch-emulator.js'))
fs.copyFileSync(toPath('../varlet-ui/es/style.css'), toPath('./public/varlet.css'))
fs.writeFileSync(
toPath('./public/varlet-area.js'),
`export default ${fs.readFileSync(toPath('../varlet-ui/json/area.json'))}`
)
},
}
}

export default defineConfig({
base: './',
Expand All @@ -16,6 +38,7 @@ export default defineConfig({
},

plugins: [
copyVarletDependencies(),
components({
resolvers: [VarletUIResolver()],
}),
Expand Down
18 changes: 1 addition & 17 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import execa from 'execa'
import fs from 'fs'
import { createSpinner } from 'nanospinner'
import { resolve } from 'path'

Expand All @@ -10,8 +9,6 @@ const PKG_ICONS = resolve(CWD, './packages/varlet-icons')
const PKG_UI = resolve(CWD, './packages/varlet-ui')
const PKG_SHARED = resolve(CWD, './packages/varlet-shared')
const PKG_USE = resolve(CWD, './packages/varlet-use')
const PKG_PLAYGROUND = resolve(CWD, './packages/varlet-ui-playground')
const PKG_EMULATOR = resolve(CWD, './packages/varlet-touch-emulator')

export const buildCli = () => execa('pnpm', ['build'], { cwd: PKG_CLI })

Expand All @@ -23,20 +20,7 @@ export const buildUse = () => execa('pnpm', ['build'], { cwd: PKG_USE })

export const buildIcons = () => execa('pnpm', ['build'], { cwd: PKG_ICONS })

export const buildUI = async () => {
await execa('pnpm', ['compile'], { cwd: PKG_UI })
copyUIToPlayground()
}

export const copyUIToPlayground = () => {
fs.copyFileSync(resolve(PKG_UI, './es/varlet.esm.js'), resolve(PKG_PLAYGROUND, './public/varlet.esm.js'))
fs.copyFileSync(resolve(PKG_EMULATOR, './index.js'), resolve(PKG_PLAYGROUND, './public/varlet-touch-emulator.js'))
fs.copyFileSync(resolve(PKG_UI, './es/style.css'), resolve(PKG_PLAYGROUND, './public/varlet.css'))
fs.writeFileSync(
resolve(PKG_PLAYGROUND, './public/varlet-area.js'),
`export default ${fs.readFileSync(resolve(PKG_UI, './json/area.json'))}`
)
}
export const buildUI = () => execa('pnpm', ['compile'], { cwd: PKG_UI })

export async function runTask(taskName, task) {
const s = createSpinner(`Building ${taskName}`).start()
Expand Down

0 comments on commit cc4554c

Please sign in to comment.