|
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
|
|
import legacy from "@vitejs/plugin-legacy";
|
|
|
|
|
import dts from "vite-plugin-dts";
|
|
|
|
|
import { resolve } from "path";
|
|
|
|
|
|
|
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
|
|
|
const isLibBuild = process.env.BUILD_LIB === "true";
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
envPrefix: ["VITE_", "VUE_"],
|
|
|
|
|
define: {
|
|
|
|
|
"process.env": "import.meta.env",
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
vue(),
|
|
|
|
|
// Only use legacy plugin for app builds, not library builds
|
|
|
|
|
!isLibBuild &&
|
|
|
|
|
legacy({
|
|
|
|
|
targets: ["defaults", "not IE 11"],
|
|
|
|
|
}),
|
|
|
|
|
// Generate TypeScript declaration files for library builds
|
|
|
|
|
isLibBuild &&
|
|
|
|
|
dts({
|
|
|
|
|
include: ["**/*.ts", "**/*.vue"],
|
|
|
|
|
exclude: ["node_modules", "dist", "dist-examples", "examples"],
|
|
|
|
|
outDir: "dist",
|
|
|
|
|
staticImport: true,
|
|
|
|
|
insertTypesEntry: true,
|
|
|
|
|
rollupTypes: false,
|
|
|
|
|
}),
|
|
|
|
|
].filter(Boolean),
|
|
|
|
|
build: isLibBuild
|
|
|
|
|
? {
|
|
|
|
|
// Library build configuration
|
|
|
|
|
sourcemap: true,
|
|
|
|
|
lib: {
|
|
|
|
|
entry: {
|
|
|
|
|
index: resolve(__dirname, "index.ts"),
|
|
|
|
|
"packages/index": resolve(__dirname, "packages/index.ts"),
|
|
|
|
|
"packages/base/index": resolve(__dirname, "packages/base/index.ts"),
|
|
|
|
|
"packages/tool/index": resolve(__dirname, "packages/tool/index.ts"),
|
|
|
|
|
"packages/manage/index": resolve(__dirname, "packages/manage/index.ts"),
|
|
|
|
|
"plugs/index": resolve(__dirname, "plugs/index.ts"),
|
|
|
|
|
"plugs/composables/index": resolve(__dirname, "plugs/composables/index.ts"),
|
|
|
|
|
"plugs/api/index": resolve(__dirname, "plugs/api/index.ts"),
|
|
|
|
|
"plugs/http/index": resolve(__dirname, "plugs/http/index.ts"),
|
|
|
|
|
"plugs/i18n/index": resolve(__dirname, "plugs/i18n/index.ts"),
|
|
|
|
|
"plugs/config/index": resolve(__dirname, "plugs/config/index.ts"),
|
|
|
|
|
"plugs/element/index": resolve(__dirname, "plugs/element/index.ts"),
|
|
|
|
|
"plugs/store/index": resolve(__dirname, "plugs/store/index.ts"),
|
|
|
|
|
"plugs/util/index": resolve(__dirname, "plugs/util/index.ts"),
|
|
|
|
|
},
|
|
|
|
|
formats: ["es"],
|
|
|
|
|
},
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
external: [
|
|
|
|
|
"vue",
|
|
|
|
|
"vue-router",
|
|
|
|
|
"vuex",
|
|
|
|
|
"vue3-i18n",
|
|
|
|
|
"element-plus",
|
|
|
|
|
"axios",
|
|
|
|
|
"dayjs",
|
|
|
|
|
"xterm",
|
|
|
|
|
"xterm-addon-attach",
|
|
|
|
|
"xterm-addon-fit",
|
|
|
|
|
"noob-mengyxu",
|
|
|
|
|
/^noob-mengyxu\//,
|
|
|
|
|
],
|
|
|
|
|
output: {
|
|
|
|
|
assetFileNames: "assets/[name][extname]",
|
|
|
|
|
entryFileNames: "[name].js",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
// App build configuration (for examples)
|
|
|
|
|
outDir: "dist-examples",
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": resolve(__dirname, "examples"),
|
|
|
|
|
"noob-mengyxu": resolve(__dirname, "index.ts"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
});
|