✨:特性 文档按需测试
This commit is contained in:
1
package/document/.env.demand
Normal file
1
package/document/.env.demand
Normal file
@@ -0,0 +1 @@
|
||||
VITE_DEV_MODE=demand
|
||||
@@ -7,6 +7,7 @@
|
||||
"homepage": "http://www.layui-vue.com",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev:demand": "vite --config ./vite.config.demand.ts",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -36,7 +37,10 @@
|
||||
"rollup": "^2.70.1",
|
||||
"typescript": "^4.6.3",
|
||||
"vite": "2.9.2",
|
||||
"vite-plugin-md": "^0.12.4"
|
||||
"vite-plugin-md": "^0.12.4",
|
||||
"unplugin-auto-import": "^0.7.1",
|
||||
"unplugin-vue-components": "^0.19.3",
|
||||
"unplugin-layui-vue-resolver": "0.0.7"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { App, createApp as _createApp } from "vue";
|
||||
import { createRouter } from "./router/index";
|
||||
import { Router } from "vue-router";
|
||||
import Store from "./store";
|
||||
import layui from "../../component/src/index";
|
||||
// import layui from "../../component/src/index";
|
||||
import LayCode from "./components/LayCode.vue";
|
||||
import LaySearch from "./components/LaySearch.vue";
|
||||
import LayTableBox from "./components/LayTableBox.vue";
|
||||
@@ -17,14 +17,31 @@ export function createApp(): {
|
||||
const app = _createApp(Layout);
|
||||
const router = createRouter();
|
||||
|
||||
app
|
||||
.use(layui)
|
||||
.use(router)
|
||||
.use(Store)
|
||||
.component("LayCode", LayCode)
|
||||
.component("LaySearch", LaySearch)
|
||||
.component("LayTableBox", LayTableBox)
|
||||
.component("LayAnchor", LayAnchor);
|
||||
console.log("DEV_MODE", import.meta.env.VITE_DEV_MODE ?? import.meta.env.DEV);
|
||||
|
||||
if (import.meta.env.VITE_DEV_MODE != "demand") {
|
||||
import("../../component/src/index").then((layui) => {
|
||||
app
|
||||
.use(layui)
|
||||
.use(router)
|
||||
.use(Store)
|
||||
.component("LayCode", LayCode)
|
||||
.component("LaySearch", LaySearch)
|
||||
.component("LayTableBox", LayTableBox)
|
||||
.component("LayAnchor", LayAnchor);
|
||||
});
|
||||
} else {
|
||||
import("../../component/src/language").then((i18n) => {
|
||||
app
|
||||
.use(i18n.default)
|
||||
.use(router)
|
||||
.use(Store)
|
||||
.component("LayCode", LayCode)
|
||||
.component("LaySearch", LaySearch)
|
||||
.component("LayTableBox", LayTableBox)
|
||||
.component("LayAnchor", LayAnchor);
|
||||
});
|
||||
}
|
||||
|
||||
return { app, router };
|
||||
}
|
||||
|
||||
70
package/document/vite.config.demand.ts
Normal file
70
package/document/vite.config.demand.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import path from "path";
|
||||
import { defineConfig } from "vite";
|
||||
import AutoImport from "unplugin-auto-import/vite";
|
||||
import Components from "unplugin-vue-components/vite";
|
||||
import { LayuiVueResolver } from "unplugin-layui-vue-resolver";
|
||||
import plugins from "./src/plugin/common-plugins";
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
"/@src": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
mode: "demand",
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes("node_modules")) {
|
||||
return id
|
||||
.toString()
|
||||
.split("node_modules/")[1]
|
||||
.split("/")[0]
|
||||
.toString();
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
AutoImport({
|
||||
// 自动导入 vue 相关函数
|
||||
imports: ["vue"],
|
||||
// 自动导入 layer-vue 相关函数,例如 layer 等
|
||||
resolvers: [
|
||||
// @ts-ignore
|
||||
LayuiVueResolver({
|
||||
exclude: [/^Lay[A-Z]/],
|
||||
}),
|
||||
],
|
||||
dts: path.resolve(path.resolve(__dirname, "src"), "auto-imports.d.ts"),
|
||||
}),
|
||||
Components({
|
||||
// 用于搜索组件的目录
|
||||
dirs: ["src/document/zh-CN/components"],
|
||||
// 允许在 'src/document/zh-CN/components' 下自动加载 markdown
|
||||
extensions: ["vue", "md"],
|
||||
// 允许自动导入和注册 markdown 中使用的组件
|
||||
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
||||
// 自动解析 layui-vue 组件
|
||||
resolvers: [
|
||||
// @ts-ignore
|
||||
LayuiVueResolver({
|
||||
resolveIcons: true,
|
||||
exclude: [
|
||||
"LaySearch",
|
||||
"LayAnchor",
|
||||
"LayTableBox",
|
||||
"LayCode",
|
||||
"component",
|
||||
"guide",
|
||||
"index",
|
||||
"resource",
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
...plugins,
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user