代码拉取完成,页面将自动刷新
import nodeResolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
import { terser } from "rollup-plugin-terser";
import commonjs from "@rollup/plugin-commonjs";
import pkg from './package.json';
import { resolve } from "path"
const outDir = resolve(".", "lib")
const libs = [
{// 浏览器导入
ext: ".browser.js",
name: toHump(pkg.name),
format: "iife",
exports: 'named',
plugins: [
typescript({ sourceMap: false, target: "es5" }),
]
},
{// 浏览器压缩版
ext: ".browser.min.js",
name: toHump(pkg.name),
format: "iife",
exports: 'named',
plugins: [
typescript({ sourceMap: false, target: "es5" }),
terser(),
]
},
{// nodejs
ext: ".cjs.js",
format: "cjs",
exports: 'named',
plugins: [
typescript({ sourceMap: false, }),
]
},
{// esm
ext: ".es.js",
format: "esm",
plugins: [
typescript({ sourceMap: false, }),
]
},
{// .d.ts
ext: ".d.ts",
format: "esm",
plugins: [
dts()
]
}
]
export default libs.map(item => {
return {
input: "./src/index.ts",
output: {
format: item.format,
name: item.name,
exports: item.exports,
file: resolve(outDir, pkg.name + item.ext)
},
plugins: [
nodeResolve(),
commonjs(),
...item.plugins
],
}
})
function toHump(name) {
return name.replace(/^(\w)/, function (a, w) {
return w.toUpperCase()
}).replace(/\-(\w)/g, function (all, letter) {
return letter.toUpperCase();
});
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。