Skip to content

Commit

Permalink
Merge pull request #139 from zh-lx/revert-135-feat-vite
Browse files Browse the repository at this point in the history
Revert "feat: 打包工具迁移至 vite"
  • Loading branch information
zh-lx authored Nov 14, 2023
2 parents ab2eaf2 + 61abde2 commit 3c489eb
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 30 deletions.
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"typings": "./types/index.d.ts",
"scripts": {
"test": "mocha",
"build": "tsc && vite build",
"build": "rollup -c && rollup -c rollup.esm.config.js",
"commit": "git-cz",
"coverage": "istanbul cover _mocha -- -R spec --timeout 15000 --recursive",
"coverage:check": "istanbul check-coverage",
Expand Down Expand Up @@ -54,6 +54,9 @@
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
Expand All @@ -64,9 +67,12 @@
"eslint": "^7.22.0",
"istanbul": "^0.4.5",
"mocha": "^8.3.2",
"tslib": "^2.6.2",
"typescript": "^4.2.3",
"vite": "^4.4.11"
"rollup": "2.60.0",
"rollup-plugin-alias": "^2.2.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.34.1",
"typescript": "^4.2.3"
},
"config": {
"commitizen": {
Expand Down
37 changes: 37 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import path from 'path';
import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs'; // commonjs模块转换插件
import cleanup from 'rollup-plugin-cleanup';
import ts from 'rollup-plugin-typescript2';
import alias from 'rollup-plugin-alias';

const plugins = [
cleanup(),
json(),
nodeResolve(),
ts({
tsconfig: path.resolve(__dirname, './tsconfig.json'), // 导入本地ts配置
clean: true,
useTsconfigDeclarationDir: true,
}),
commonjs(),
alias({
entries: [{ find: '@', replacement: './lib' }],
}),
terser(),
];

module.exports = {
input: path.resolve('./lib/index.ts'),
output: [
{
exports: 'auto',
file: path.resolve(__dirname, './dist/index.js'),
format: 'umd',
name: 'pinyinPro',
},
],
plugins,
};
33 changes: 33 additions & 0 deletions rollup.esm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import path from 'path';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs'; // commonjs模块转换插件
import ts from 'rollup-plugin-typescript2';
import alias from 'rollup-plugin-alias';

const plugins = [
json(),
nodeResolve(),
ts({
tsconfig: path.resolve(__dirname, './tsconfig.json'), // 导入本地ts配置
clean: true,
useTsconfigDeclarationDir: true,
}),
commonjs(),
alias({
entries: [{ find: '@', replacement: './lib' }],
}),
];

module.exports = {
input: path.resolve('./lib/index.ts'),
output: [
{
exports: 'auto',
file: path.resolve(__dirname, './dist/index.mjs'),
format: 'es',
sourcemap: false,
},
],
plugins,
};
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES5",
"target": "es6",
"module": "esnext",
"strict": true,
"jsx": "preserve",
Expand All @@ -10,16 +10,13 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"isolatedModules": false,
"downlevelIteration": true,
"sourceMap": false,
"declaration": true,
"declarationDir": "types",
"emitDeclarationOnly": true,
"baseUrl": "./",
"paths": {
"@/*": ["lib/*"]
}
},
"include": ["lib/**/*.ts"],
"exclude": ["node_modules", "types"]
}
22 changes: 0 additions & 22 deletions vite.config.ts

This file was deleted.

0 comments on commit 3c489eb

Please sign in to comment.