layui/package/layer/vite.config.ts

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-04-05 10:31:31 +08:00
import { defineConfig } from "vite";
import { name } from "./package.json";
import { babel } from "@rollup/plugin-babel";
2022-04-05 10:31:31 +08:00
import vue from "@vitejs/plugin-vue";
import path from "path";
const camelize = (name: string) =>
name.replace(/(^|-)(\w)/g, (a, b, c) => c.toUpperCase());
export default defineConfig({
resolve: {
alias: {
"/@src": path.resolve(__dirname, "src"),
},
},
plugins: [vue()],
build: {
target: "es2015",
outDir: path.resolve(__dirname, "lib"),
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
name: camelize(name),
},
rollupOptions: {
output: {
exports: "named",
globals: (id: string) => {
const name = id.replace(/^@/, "").split("/")[0];
return camelize(name);
},
assetFileNames: "index.css",
},
2022-06-25 17:05:04 +08:00
plugins: [
babel({
babelHelpers: 'runtime',
2022-06-25 17:05:04 +08:00
exclude: "node_modules/**",
extensions: [".js", ".jsx", ".ts", ".tsx", ".vue"],
presets: ["@babel/preset-env", "@babel/preset-typescript"],
plugins: [
[
'@babel/plugin-transform-runtime',
],
]
2022-06-25 17:05:04 +08:00
}),
],
2022-04-05 10:31:31 +08:00
external: ["vue"],
},
},
});