45 Star 136 Fork 91

GVPHalo-E/HaloE-Design

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.js 3.65 KB
一键复制 编辑 原始数据 按行查看 历史
zhangjinpeng 提交于 2023-10-11 23:13 . fix:修复打包问题
/// <reference types="vitest" />
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { resolve } from 'path'
import DefineOptions from 'unplugin-vue-define-options/vite'
// import Components from 'unplugin-vue-components/vite'
const path = require("path");
const config = defineConfig({
plugins: [vue(), vueJsx(),
// @ts-ignore
// Components({
// // 指定组件位置,默认是src/components
// dirs: ["src/components"],
// extensions: ["vue"],
// deep: true,
// // 配置文件生成位置
// dts: "types/components.d.ts",
// }),
DefineOptions()
],
target: "es2015",
alias: {
"@": resolve(__dirname, 'src'), // 路径别名
},
build: {
outDir: path.resolve(__dirname, "./dist"),
lib: {
entry: path.resolve(__dirname, "./src/index.js"),
name: "HaloEDesign",
},
rollupOptions: {
context: "globalThis",
preserveEntrySignatures: "strict",
external: ["vue"],
output: [
{
format: "umd",
exports: "named",
sourcemap: false,
entryFileNames: "haloe.min.js",
chunkFileNames: "[name].js",
assetFileNames: "[name].[ext]",
namespaceToStringTag: true,
inlineDynamicImports: false,
manualChunks: undefined,
globals: { vue: "Vue" },
},
{
format: "es",
exports: "named",
sourcemap: false,
entryFileNames: "haloe.min.esm.js",
chunkFileNames: "[name].js",
assetFileNames: "[name].[ext]",
namespaceToStringTag: true,
inlineDynamicImports: false,
manualChunks: undefined,
globals: { vue: "Vue" },
},
{
format: "es",
exports: "named",
sourcemap: false,
// 配置打包根目录
dir: 'dist/es',
preserveModulesRoot: 'src',
entryFileNames: '[name].js',
preserveModules: true,
chunkFileNames: "[name].js",
assetFileNames: "[name].[ext]",
namespaceToStringTag: true,
inlineDynamicImports: false,
manualChunks: undefined,
globals: { vue: "Vue" },
},
{
format: 'cjs',
entryFileNames: '[name].js',
preserveModules: true,
dir: 'dist/lib',
preserveModulesRoot: 'src',
exports: "named",
sourcemap: false,
// 配置打包根目录
chunkFileNames: "[name].js",
assetFileNames: "[name].[ext]",
namespaceToStringTag: true,
inlineDynamicImports: false,
manualChunks: undefined,
globals: { vue: "Vue" },
}
],
},
},
resolve: {
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
},
css: {
preprocessorOptions: {
less:{
charset: false,
additionalData: `@use "${path.resolve(__dirname, 'src/styles/index.less')}"`
}
}
},
define: {
'process.env': { ...process.env }
},
test: {
// 模拟dom环境
environment: "happy-dom",
coverage: {
// 覆盖率提供者
provider: "istanbul",
reporter: ["text", "json", "html"],
// 设置覆盖文件夹
reportsDirectory: "./coverage",
// 检查每个文件的阈值
perFile: true,
// 设置代码覆盖率阈值
lines: 75,
functions: 75,
branches: 75,
statements: 75,
},
// open: true,
// ui:true,
include: ["./src/components/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
},
});
export default config;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/halo-e/haloe-design.git
git@gitee.com:halo-e/haloe-design.git
halo-e
haloe-design
HaloE-Design
develop

搜索帮助