vite-bolt/plugin/build/vite.conf.ts

49 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2023-02-01 17:52:53 +08:00
import path from "path";
/**
* doc vite构建配置
*/
const docPage = { outDir: "dist/doc" };
/**
* lib vite构建配置
*/
const componentLib = {
minify: true, // boolean | 'terser' | 'esbuild'
sourcemap: true, // 输出单独 source文件
brotliSize: true, // 生成压缩大小报告
cssCodeSplit: false, // css 从 js 组件中分离出去
rollupOptions: {
external: ["react", "react-dom", /\.less/], // 忽略js 中的 less 文件
output: [
{
format: "es",
entryFileNames: "[name].js",
preserveModules: true,
dir: "dist/ui",
preserveModulesRoot: "src",
// assetFileNames: (assetInfo) => processAssets(assetInfo),
},
],
},
lib: {
entry: path.resolve(process.cwd(), "src/index.ts"),
name: "Bolt", // 暴露的全局变量名称
},
};
export const build = (mode: string, config = {}) => {
switch (mode) {
case "doc":
config = docPage;
break;
case "lib":
config = componentLib;
break;
default:
config = {};
break;
}
return config;
};