麻烦问下老师关于rollup
来源:11-7 【放大招了】rollup vue 组件编译

hy_wang
2020-09-17
const rollup = require('rollup')
const inputOptions = require('./input')
const outputOptions = require('./output')
async function rollupBuild(input, output) {
const bundle = await rollup.rollup(input) // 根据input配置进行打包
console.log(`正在生成:${output.file}`)
await bundle.write(output) // 根据output配置输出文件
console.log(`${output.file}生成成功!`)
}
(async function () {
for (let i = 0; i < outputOptions.length; i++) {
await rollupBuild(inputOptions, outputOptions[i])
}
})()
请问下老师我和你的配置是一样的。。和官网也是一样
build的时候总是提醒
[!] Error: Config file must export an options object, or an array of options objectshttps://rollupjs.org/guide/en/#configuration-files
我看官网都没有export,为什么一直error
写回答
2回答
-
hy_wang
提问者
2020-09-17
// 需要nodejs分析模块 所以使用Commonjs模块 const path = require("path") module.exports = { input: path.resolve(__dirname, '../../src/index.js') }
const path = require("path") module.exports = [{ file: path.resolve(__dirname, "../../distAll/index.global.js"), format: "umd", name: "qingfeng", banner: "// please use umd" }, { file: path.resolve(__dirname, "../../distAll/index.esm.js"), format: "es", name: "qingfeng", banner: "// please use esm" }, { file: path.resolve(__dirname, "../../distAll/index.cjs.js"), format: "cjs", name: "qingfeng", banner: "// please use commomjs" } ]
build的文件
// const rollup = require("rollup") // const input = require("./input") // const output = require("./output") // async function build(input, output) { // const bundle = await rollup.rollup(input) // console.log(`${bundle},打包完成`) // await bundle.write(output) // } // (async function () { // for (let i of output) { // await build(input, i) // } // }()) const rollup = require('rollup') const inputOptions = require('./input') const outputOptions = require('./output') async function rollupBuild(input, output) { const bundle = await rollup.rollup(input) // 根据input配置进行打包 console.log(`正在生成:${output.file}`) await bundle.write(output) // 根据output配置输出文件 console.log(`${output.file}生成成功!`) } (async function () { for (let i = 0; i < outputOptions.length; i++) { await rollupBuild(inputOptions, outputOptions[i]) } })()
00 -
扬_灵
2020-09-17
同学你好,这个报错信息是配置文件必须导出options为对象或是数组,你可以看一下配置文件中返回的信息是什么或者把代码上传一下,我在本地帮你定位问题。
032020-09-18
相似问题