You've already forked uniapp-error-monitor
解决以下问题: - 修复package.json中repository URL的拼写错误 - 添加缺失的构建依赖项(@rollup/plugin-babel, @babel/core等) - 修复TypeScript类型定义中的字段名冲突 - 修复JavaScript代码中的import.meta语法错误 - 移除JavaScript文件中不当的类型导出 - 添加缺失的LICENSE文件 - 完善package.json配置(添加browser字段等) 确保项目能够成功构建和发布到npm。 Fixes: npm publish失败问题 Closes: 构建配置优化
78 lines
1.4 KiB
JavaScript
78 lines
1.4 KiB
JavaScript
import { defineConfig } from 'rollup'
|
|
import babel from '@rollup/plugin-babel'
|
|
import { terser } from 'rollup-plugin-terser'
|
|
import typescript from '@rollup/plugin-typescript'
|
|
|
|
const pkg = require('./package.json')
|
|
|
|
const external = [
|
|
'vue',
|
|
'vue3',
|
|
'@dcloudio/uni-app',
|
|
'@dcloudio/uni-core',
|
|
'uniapp'
|
|
]
|
|
|
|
const plugins = [
|
|
typescript(),
|
|
babel({
|
|
babelHelpers: 'bundled',
|
|
extensions: ['.js', '.ts'],
|
|
exclude: ['node_modules/**'],
|
|
presets: [
|
|
['@babel/preset-env', {
|
|
modules: false,
|
|
targets: {
|
|
esmodules: true
|
|
}
|
|
}]
|
|
]
|
|
})
|
|
]
|
|
|
|
export default defineConfig([
|
|
{
|
|
input: 'src/index.js',
|
|
output: [
|
|
// ESM 输出
|
|
{
|
|
file: pkg.module,
|
|
format: 'es',
|
|
sourcemap: true
|
|
},
|
|
// UMD 输出 (用于浏览器)
|
|
{
|
|
file: pkg.browser,
|
|
format: 'umd',
|
|
name: 'UniAppErrorMonitor',
|
|
sourcemap: true,
|
|
globals: {
|
|
'vue': 'Vue'
|
|
}
|
|
},
|
|
// CommonJS 输出 (用于 Node.js)
|
|
{
|
|
file: pkg.main,
|
|
format: 'cjs',
|
|
sourcemap: true
|
|
}
|
|
],
|
|
external,
|
|
plugins
|
|
},
|
|
// 生产环境构建 (压缩版本)
|
|
{
|
|
input: 'src/index.js',
|
|
output: [
|
|
{
|
|
file: pkg.browser.replace('.umd.js', '.umd.min.js'),
|
|
format: 'umd',
|
|
name: 'UniAppErrorMonitor',
|
|
sourcemap: false,
|
|
plugins: [terser()]
|
|
}
|
|
],
|
|
external,
|
|
plugins
|
|
}
|
|
]) |