rollup 的多个 input 的配置文件 怎么写

module.exports = (env = 'production') => {
  return {
  input: path.join(\_\_dirname, '../src/render/main/index.ts'),
  output: {
  file: path.join(\_\_dirname, '../src/render/main/\_.js'),
  format: 'cjs',
  name: 'ElectronMainBundle',
  sourcemap: true,
  }, 
// input:path.join(\_\_dirname, '../src/render/nested/server/main.ts'),
// output:{
// file: path.join(\_\_dirname, '../src/render/nested/server/main.js'),
// format: 'cjs',
// name: 'ElectronServer',
// sourcemap: true,
// },
// input:path.join(\_\_dirname, '../src/render/nested-first/server/main.ts'),
// output:{
// file: path.join(\_\_dirname, '../src/render/nested-first/server/main.js'),
// format: 'cjs',
// name: 'ElectronServer',
// sourcemap: true,
// },
plugins: [
nodeResolve({ jsnext: true, preferBuiltins: true, browser: true }), // 消除碰到 node.js 模块时⚠警告
commonjs(),
typescript(),
],
external: [
'fs',
'path',
'http',
'https',
'child\_process',
'os',
'electron',
],
}
};

我写的多个 input 只有一个生效了

阅读 8.6k
1 个回答
module.exports = (env = 'production') => {
  return [{
    input: path.join(__dirname, '../src/main/index.ts'),
    output: {
      file: path.join(__dirname, '../src/main/_.js'),
      format: 'cjs',
      name: 'ElectronMainBundle',
      sourcemap: true,
    }, 
    plugins: [
      nodeResolve({ jsnext: true, preferBuiltins: true, browser: true }), // 消除碰到 node.js 模块时⚠警告
      commonjs(),
      typescript(),
    ],
    external: [
      'fs',
      'path',
      'http',
      'https',
      'child_process',
      'os',
      'electron',
    ],
  },
  {
    input:path.join(__dirname, '../src/render/nested-first/server/main.ts'),
    output:{
      file: path.join(__dirname, '../src/render/nested-first/server/main.js'),
      format: 'cjs',
      name: 'ElectronServer',
      sourcemap: true,
    },
    plugins: [
      nodeResolve({ jsnext: true, preferBuiltins: true, browser: true }), // 消除碰到 node.js 模块时⚠警告
      commonjs(),
      typescript(),
    ],
    external: [
      'fs',
      'path',
      'http',
      'https',
      'child_process',
      'os',
      'electron',
    ],
  },
  {
    input:path.join(__dirname, '../src/render/nested-second/server/main.ts'),
    output:{
      file: path.join(__dirname, '../src/render/nested-second/server/main.js'),
      format: 'cjs',
      name: 'ElectronServer',
      sourcemap: true,
    },
    plugins: [
      nodeResolve({ jsnext: true, preferBuiltins: true, browser: true }), // 消除碰到 node.js 模块时⚠警告
      commonjs(),
      typescript(),
    ],
    external: [
      'fs',
      'path',
      'http',
      'https',
      'child_process',
      'os',
      'electron',
    ],
  }
]
};
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进