mirror of
https://git.ddmt.top/ddmt/ddmt-tool.git
synced 2026-03-23 05:17:06 +00:00
build(package): 重构项目并添加 Rollup 构建配置
- 修改 package.json 中的 exports 字段,支持 CommonJS 和 ES 模块 - 添加 build 脚本,使用 Rollup 进行构建 - 新增 devDependencies,包含 Babel 和 Rollup 相关插件
This commit is contained in:
30
rollup.config.js
Normal file
30
rollup.config.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import babel from '@rollup/plugin-babel';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
|
||||
export default [
|
||||
{
|
||||
input: 'index.js', // 入口文件
|
||||
output: {
|
||||
file: 'dist/index.mjs', // 输出 ESM 文件
|
||||
format: 'esm', // 输出格式为 ESM
|
||||
},
|
||||
plugins: [
|
||||
resolve(), // 解析第三方模块
|
||||
commonjs(), // 将 CommonJS 模块转换为 ESM
|
||||
babel({ babelHelpers: 'bundled' }), // 使用 Babel 转译
|
||||
],
|
||||
},
|
||||
{
|
||||
input: 'index.js', // 入口文件
|
||||
output: {
|
||||
file: 'dist/index.cjs', // 输出 CommonJS 文件
|
||||
format: 'cjs', // 输出格式为 CommonJS
|
||||
},
|
||||
plugins: [
|
||||
resolve(), // 解析第三方模块
|
||||
commonjs(), // 将 CommonJS 模块转换为 ESM
|
||||
babel({ babelHelpers: 'bundled' }), // 使用 Babel 转译
|
||||
],
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user