feat:add lib mode build script
This commit is contained in:
+3
-1
@@ -2,10 +2,12 @@
|
||||
"version": "0.5.0",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"lib": "tsc && vite build --mode lib",
|
||||
"build": "tsc && vite build --mode app",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.12",
|
||||
"typescript": "^4.3.2",
|
||||
"vite": "^2.4.2"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
export function debounce(func: Function, delay: number) {
|
||||
let timer: number
|
||||
return function (...args: any) {
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
if (timer) {
|
||||
window.clearTimeout(timer)
|
||||
}
|
||||
timer = window.setTimeout(() => {
|
||||
// @ts-ignore
|
||||
func.apply(this, args)
|
||||
}, delay)
|
||||
|
||||
+22
-3
@@ -1,5 +1,24 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, UserConfig } from 'vite'
|
||||
import * as path from 'path'
|
||||
|
||||
export default defineConfig({
|
||||
base: '/canvas-editor/'
|
||||
export default defineConfig(({ mode }) => {
|
||||
const name = 'canvas-editor'
|
||||
const defaultOptions: UserConfig = {
|
||||
base: `/${name}/`
|
||||
}
|
||||
if (mode === 'lib') {
|
||||
return {
|
||||
...defaultOptions,
|
||||
build: {
|
||||
lib: {
|
||||
name,
|
||||
fileName: (format) => `${name}.${format}.js`,
|
||||
entry: path.resolve(__dirname, 'src/editor/index.ts')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
...defaultOptions
|
||||
}
|
||||
})
|
||||
@@ -2,6 +2,11 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/node@^16.11.12":
|
||||
version "16.11.12"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.12.tgz#ac7fb693ac587ee182c3780c26eb65546a1a3c10"
|
||||
integrity sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==
|
||||
|
||||
esbuild-android-arm64@0.13.13:
|
||||
version "0.13.13"
|
||||
resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.13.13.tgz#da07b5fb2daf7d83dcd725f7cf58a6758e6e702a"
|
||||
|
||||
Reference in New Issue
Block a user