81 lines
2.1 KiB
JavaScript
81 lines
2.1 KiB
JavaScript
|
|
import path from "node:path";
|
||
|
|
import fs from "node:fs";
|
||
|
|
import { fileURLToPath } from "node:url";
|
||
|
|
import { defineConfig } from "vite";
|
||
|
|
import vue from "@vitejs/plugin-vue";
|
||
|
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||
|
|
|
||
|
|
const __filename = fileURLToPath(import.meta.url);
|
||
|
|
const rootDir = path.dirname(__filename);
|
||
|
|
const pkg = JSON.parse(
|
||
|
|
fs.readFileSync(path.resolve(rootDir, "package.json"), "utf8"),
|
||
|
|
);
|
||
|
|
|
||
|
|
export default defineConfig({
|
||
|
|
define: {
|
||
|
|
__PRINT_TEMPLATE_VERSION__: JSON.stringify(pkg.version || "0.0.0"),
|
||
|
|
},
|
||
|
|
plugins: [
|
||
|
|
vue({
|
||
|
|
script: {
|
||
|
|
babelParserPlugins: ["jsx"],
|
||
|
|
},
|
||
|
|
}),
|
||
|
|
vueJsx(),
|
||
|
|
],
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
"@": path.resolve(rootDir, "packages/designer/src"),
|
||
|
|
"@h3/theme-pc/core/index.scss": path.resolve(
|
||
|
|
rootDir,
|
||
|
|
"./styles/h3-theme-stub.scss",
|
||
|
|
),
|
||
|
|
"element-plus-cisdi": path.resolve(
|
||
|
|
rootDir,
|
||
|
|
"node_modules/element-plus",
|
||
|
|
),
|
||
|
|
'@busi-comp': path.resolve(rootDir, '../../packages/business-components/src'),
|
||
|
|
'~@': path.resolve(rootDir, '../../packages/form-designer/src'),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
css: {
|
||
|
|
preprocessorOptions: {
|
||
|
|
scss: {
|
||
|
|
additionalData: `@import "${path
|
||
|
|
.resolve(rootDir, "./styles/h3-theme-stub.scss")
|
||
|
|
.replace(/\\/g, "/")}";\n`,
|
||
|
|
// 忽略 Sass 弃用警告(@import 等)
|
||
|
|
silenceDeprecations: ['import', 'color-functions', 'global-builtin'],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
outDir: "dist",
|
||
|
|
emptyOutDir: true,
|
||
|
|
lib: {
|
||
|
|
entry: {
|
||
|
|
index: path.resolve(rootDir, "src/index.ts")
|
||
|
|
},
|
||
|
|
fileName: (format, entryName) => {
|
||
|
|
return `${entryName}.mjs`;
|
||
|
|
},
|
||
|
|
formats: ["es"],
|
||
|
|
},
|
||
|
|
rollupOptions: {
|
||
|
|
external: (id) => {
|
||
|
|
if (id === "vue" || id.startsWith("vue/")) return true;
|
||
|
|
if (id.startsWith("@h3/")) return true;
|
||
|
|
if (id === "element-plus-cisdi" || id.startsWith("element-plus-cisdi/"))
|
||
|
|
return true;
|
||
|
|
if (
|
||
|
|
id === "@element-plus/icons-vue" ||
|
||
|
|
id.startsWith("@element-plus/icons-vue/")
|
||
|
|
)
|
||
|
|
return true;
|
||
|
|
return false;
|
||
|
|
},
|
||
|
|
output: {},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
});
|