Skip to content

Commit

Permalink
新增 dts 声明文件, 锁定strip-ansi和string-width依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
sengoku-f committed Sep 20, 2024
1 parent 256cdc2 commit 9f16cad
Show file tree
Hide file tree
Showing 4 changed files with 634 additions and 679 deletions.
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ksw-rpom-icon-vue",
"version": "0.1.4",
"version": "0.1.5",
"license": "ISC",
"description": "KSW RPOM ICON",
"main": "packages/cjs/index.js",
Expand All @@ -14,7 +14,7 @@
"packages/*/*/*.d.ts"
],
"scripts": {
"serve": "vue-cli-service serve",
"dev": "vue-cli-service serve",
"build": "vue-cli-service build",
"build:icons": "rm -rf src/icons && node bin/build.mjs",
"build:code": "rollup -c",
Expand All @@ -29,7 +29,6 @@
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
Expand All @@ -40,20 +39,24 @@
"core-js": "^3.8.3",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"gsap": "^3.12.5",
"postcss": "^8.4.41",
"prettier": "^3.3.3",
"rollup": "^4.20.0",
"rollup-plugin-empty-dir": "^1.0.5",
"rollup-plugin-delete": "^2.1.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-vue": "^6.0.0",
"svgo": "^3.3.2",
"tailwindcss": "^3.4.9",
"typescript": "^5.6.2",
"vue": "^2.6.14",
"vue-clipboard2": "^0.3.3",
"vue-m-message": "3",
"vue-template-compiler": "^2.6.14"
},
"resolutions": {
"strip-ansi": "<7.0.0",
"string-width": "<5.0.0"
},
"eslintConfig": {
"root": true,
"env": {
Expand Down
96 changes: 0 additions & 96 deletions rollup.config.js

This file was deleted.

98 changes: 98 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

import { nodeResolve } from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import del from 'rollup-plugin-delete'
import dts from "rollup-plugin-dts";
import { terser } from "rollup-plugin-terser";
import path from "path";
import { fileURLToPath } from "url";
import { globSync } from "glob";

// 获取当前模块文件的 URL (ES模块)
const __filename = fileURLToPath(import.meta.url);
// 获取当前模块目录的路径
const __dirname = path.dirname(__filename);

// 获取/icons文件夹下的所有图标名称
function getIconExternals() {
const iconFiles = globSync(path.resolve(__dirname, "src/icons/*.js"));
return iconFiles.map(
(file) => `./icons/${path.basename(file, path.extname(file))}`
);
}

// 获取多入口文件输入
function getFileInput() {
const files = globSync([
"src/index.js",
"src/map.js",
"src/runtime/*.js",
"src/icons/*.js",
]);
return Object.fromEntries(
files.map((file) => [
path.relative(
// 相对于 `src` 文件夹生成相对路径
"src",
file.slice(0, file.length - path.extname(file).length)
),
file,
])
);
}

// 默认参数
const baseOutputConfig = {
// compact: true,
// entryFileNames: '[name].js',
chunkFileNames: "[name].js",
globals: {
vue: "Vue",
},
// manualChunks: {
// gsap: ["gsap"],
// },
};

export default [
{
input: getFileInput(),
external: ["vue", "./map", "../runtime", ...getIconExternals()],
plugins: [
del({ targets: 'packages/*' }),
nodeResolve(),
babel({
babelHelpers: "runtime",
exclude: "node_modules/**",
}),
terser(),
],
output: [
{
format: "es",
dir: "packages/es",
...baseOutputConfig,
},
{
format: "cjs",
dir: "packages/cjs",
...baseOutputConfig,
},
],
},
{
input: getFileInput(),
external: ["vue", "./map", "../runtime", ...getIconExternals()],
plugins: [dts()],
output: [
{
dir: "packages/es",
format: "es",
},
{
dir: "packages/cjs",
format: "cjs",
},
],
},
];
Loading

0 comments on commit 9f16cad

Please sign in to comment.