Match-id-ba152d3826b0421b83dcfbb4aeb8f0f464ed08db
This commit is contained in:
commit
c225c0b3e3
|
@ -0,0 +1,52 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
|
||||
function deleteFolder(filePath) {
|
||||
if (fs.existsSync(filePath)) {
|
||||
if (fs.lstatSync(filePath).isDirectory()) {
|
||||
const files = fs.readdirSync(filePath);
|
||||
files.forEach(file => {
|
||||
const nextFilePath = path.join(filePath, file);
|
||||
const states = fs.lstatSync(nextFilePath);
|
||||
if (states.isDirectory()) {
|
||||
deleteFolder(nextFilePath);
|
||||
} else {
|
||||
fs.unlinkSync(nextFilePath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(filePath);
|
||||
} else if (fs.lstatSync(filePath).isFile()) {
|
||||
fs.unlinkSync(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param folders {string[]}
|
||||
* @returns {{buildEnd(): void, name: string}}
|
||||
*/
|
||||
export function cleanUp(folders) {
|
||||
return {
|
||||
name: 'clean-up',
|
||||
buildEnd() {
|
||||
folders.forEach(f => deleteFolder(f));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function buildTypeConfig() {
|
||||
return {
|
||||
input: './build/@types/index.d.ts',
|
||||
output: {
|
||||
file: './build/index.d.ts',
|
||||
format: 'es',
|
||||
},
|
||||
plugins: [dts(), cleanUp(['./build/@types/example', './build/@types/src'])],
|
||||
};
|
||||
}
|
||||
|
||||
export default [buildTypeConfig()];
|
|
@ -7,7 +7,8 @@
|
|||
"types": "build/index.d.ts",
|
||||
"scripts": {
|
||||
"demo-serve": "webpack serve --mode=development",
|
||||
"rollup-build": "rollup --config rollup.config.js",
|
||||
"rollup-build": "rollup --config rollup.config.js && npm run build-types ",
|
||||
"build-types": "tsc -p tsconfig.json && rollup -c build-type.js",
|
||||
"test": "jest --config jest.config.js",
|
||||
"test-c": "jest --coverage"
|
||||
},
|
||||
|
@ -16,8 +17,7 @@
|
|||
"url": ""
|
||||
},
|
||||
"files": [
|
||||
"build",
|
||||
"example"
|
||||
"build"
|
||||
],
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
@ -50,6 +50,7 @@
|
|||
"rollup-plugin-livereload": "^2.0.5",
|
||||
"rollup-plugin-serve": "^1.1.0",
|
||||
"rollup-plugin-terser": "^5.3.0",
|
||||
"rollup-plugin-dts": "^6.0.1",
|
||||
"tslib": "^2.6.1",
|
||||
"ts-jest": "29.0.3",
|
||||
"ts-node": "10.9.1",
|
||||
|
@ -57,7 +58,8 @@
|
|||
"webpack": "^5.81.0",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"webpack-dev-server": "^4.13.3",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
"react": "18.2.0-h3",
|
||||
"react-dom": "18.2.0-h3",
|
||||
"core-js": "3.31.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
"declaration": true,
|
||||
"experimentalDecorators": true,
|
||||
"downlevelIteration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"declarationDir": "./build/@types",
|
||||
// 赋值为空数组使@types/node不会起作用
|
||||
"lib": [
|
||||
"dom",
|
||||
|
@ -53,19 +55,23 @@
|
|||
}
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"./src/format/**/*.ts",
|
||||
"./example/**/*"
|
||||
"./index.ts",
|
||||
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib",
|
||||
"**/*.spec.ts",
|
||||
"dev"
|
||||
"dev",
|
||||
"./example/**/*",
|
||||
"./tsconfig.json"
|
||||
],
|
||||
"types": [
|
||||
"node",
|
||||
"jest",
|
||||
"@testing-library/jest-dom"
|
||||
],
|
||||
"files": [
|
||||
"./index.ts"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue