diff --git a/devui/vue-devui.ts b/devui/vue-devui.ts new file mode 100644 index 0000000000000000000000000000000000000000..3ac018e8da556d7fb8b061b98010bb236abf6a9a --- /dev/null +++ b/devui/vue-devui.ts @@ -0,0 +1,28 @@ +import { App } from 'vue'; + +import Alert from './alert/alert'; +import Button from './button/button'; +import Checkbox from './checkbox/src/checkbox'; +import Panel from './panel/panel'; +import Radio from './radio/src/radio'; +import Tabs from './tabs/tabs'; +import Toggle from './toggle/src/toggle'; + +function install(app: App) { + const packages = [ + Alert, Button, Checkbox, Panel, Radio, Tabs, Toggle, + ]; + packages.forEach((item:any) => { + if (item.install) { + app.use(item); + } else if (item.name) { + app.component(item.name, item); + } + }); +} + +export { + Alert, Button, Checkbox, Panel, Radio, Tabs, Toggle, +}; + +export default { install, version: '0.0.1' }; diff --git a/package.json b/package.json index 6898099c2ea398a13dc85f9e4cc6b2fd95d18ff6..db1da80f8fc6366c87c763d84dad94d8a8ce94e8 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,20 @@ { "name": "vue-devui", - "version": "0.0.0", + "version": "0.0.1", "license": "MIT", "description": "DevUI components based on Vite and Vue3", + "main": "vue-devui.umd.js", + "module": "vue-devui.es.js", + "style": "style.css", "scripts": { "dev": "vite", "build": "vite build", + "build:lib": "vite build --config vite.config.build.ts && cp package.json dist", "test": "jest --config jest.config.js", "lint": "eslint \"{src,devui}/**/*.{vue,js,ts,jsx,tsx}\"", "lint:fix": "eslint --fix \"{src,devui}/**/*.{vue,js,ts,jsx,tsx}\"", - "convert:route": "node ./scripts/convert-component-route.js" + "convert:route": "node ./scripts/convert-component-route.js", + "publish": "cd dist && npm publish" }, "dependencies": { "@types/lodash-es": "^4.17.4", diff --git a/vite.config.build.ts b/vite.config.build.ts new file mode 100644 index 0000000000000000000000000000000000000000..2605d49cf7246b3d8b9ab9ac755349d22e8f6d5e --- /dev/null +++ b/vite.config.build.ts @@ -0,0 +1,33 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx'; +import markdown from 'vite-plugin-md'; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [ + vue({ + include: [/\.vue$/, /\.md$/], + }), + vueJsx({}), + markdown() + ], + build: { + rollupOptions: { + // 请确保外部化那些你的库中不需要的依赖 + external: ['vue', 'vue-router'], + output: { + // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量 + globals: { + vue: 'Vue' + } + } + }, + lib: { + entry: 'devui/vue-devui.ts', + name: 'vue-devui', + fileName: 'vue-devui', + formats: ['es', 'umd'] + } + } +})