49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
|
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;
|
||
|
};
|