2020-12-24 10:17:27 +08:00
|
|
|
import { join } from 'path'
|
|
|
|
import { RollupOptions } from 'rollup'
|
2021-05-15 14:53:43 +08:00
|
|
|
import nodeResolve from '@rollup/plugin-node-resolve'
|
2020-12-24 10:17:27 +08:00
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
2021-05-15 14:53:43 +08:00
|
|
|
import typescript from '@rollup/plugin-typescript'
|
2020-12-24 10:17:27 +08:00
|
|
|
import alias from '@rollup/plugin-alias'
|
|
|
|
import json from '@rollup/plugin-json'
|
2021-04-01 10:30:24 +08:00
|
|
|
import { builtins } from './utils'
|
2020-08-16 20:42:52 +08:00
|
|
|
|
2020-12-24 10:17:27 +08:00
|
|
|
export default (env = 'production') => {
|
|
|
|
const options: RollupOptions = {
|
|
|
|
input: join(__dirname, '../src/main/index.ts'),
|
2020-08-16 20:42:52 +08:00
|
|
|
output: {
|
2021-05-15 14:53:43 +08:00
|
|
|
file: join(__dirname, '../dist/main/index.js'),
|
2020-08-16 20:42:52 +08:00
|
|
|
format: 'cjs',
|
|
|
|
name: 'ElectronMainBundle',
|
|
|
|
sourcemap: true,
|
|
|
|
},
|
|
|
|
plugins: [
|
2021-05-15 14:53:43 +08:00
|
|
|
nodeResolve(),
|
2020-08-16 20:42:52 +08:00
|
|
|
commonjs(),
|
2020-09-06 17:35:02 +08:00
|
|
|
json(),
|
2021-05-15 14:53:43 +08:00
|
|
|
typescript({
|
|
|
|
module: 'ESNext',
|
2020-08-26 18:24:01 +08:00
|
|
|
}),
|
2020-09-06 17:35:02 +08:00
|
|
|
alias({
|
|
|
|
entries: [
|
2021-05-15 20:57:32 +08:00
|
|
|
{ find: '@render', replacement: join(__dirname, '../src/render') },
|
|
|
|
{ find: '@main', replacement: join(__dirname, '../src/main') },
|
|
|
|
{ find: '@src', replacement: join(__dirname, '../src') },
|
|
|
|
{ find: '@root', replacement: join(__dirname, '..') },
|
2020-09-06 17:35:02 +08:00
|
|
|
]
|
2020-12-24 18:36:41 +08:00
|
|
|
}),
|
2020-08-16 20:42:52 +08:00
|
|
|
],
|
2021-04-01 10:30:24 +08:00
|
|
|
external: [
|
|
|
|
...builtins(),
|
|
|
|
'electron',
|
|
|
|
],
|
2020-08-16 20:42:52 +08:00
|
|
|
}
|
2020-12-24 10:17:27 +08:00
|
|
|
|
|
|
|
return options
|
2020-08-26 18:24:01 +08:00
|
|
|
}
|