代码拉取完成,页面将自动刷新
import { spawn } from 'child_process';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import builtinModules from 'builtin-modules';
import electron from 'electron';
import copy from 'rollup-plugin-copy';
import appManifest from './package.json';
const NODE_ENV = process.env.NODE_ENV || 'development';
const canRun = process.env.ROLLUP_WATCH === 'true' && process.env.NO_RUN !== 'true';
const run = () => {
if (!canRun) {
return;
}
let proc = null;
return {
writeBundle: async () => {
if (proc) {
proc.kill();
await new Promise((resolve) => proc.on('close', resolve));
}
console.log(proc ? 'Restarting main process...' : 'Starting main process...');
proc = spawn(electron, ['.'], { stdio: 'inherit' });
proc.on('close', () => {
proc = null;
});
},
};
};
export default [
{
external: [
...builtinModules,
...Object.keys(appManifest.dependencies),
...Object.keys(appManifest.devDependencies),
].filter((moduleName) => moduleName !== '@bugsnag/js'),
input: 'src/rootWindow.ts',
preserveEntrySignatures: 'strict',
plugins: [
json(),
replace({
'process.env.BUGSNAG_API_KEY': JSON.stringify(process.env.BUGSNAG_API_KEY),
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
}),
typescript({
noEmitOnError: false,
}),
babel({
babelHelpers: 'bundled',
}),
nodeResolve({
browser: true,
}),
commonjs(),
],
output: {
dir: 'app',
format: 'cjs',
sourcemap: true,
},
},
{
external: [
...builtinModules,
...Object.keys(appManifest.dependencies),
...Object.keys(appManifest.devDependencies),
].filter((moduleName) => moduleName !== '@bugsnag/js'),
input: 'src/preload.ts',
plugins: [
json(),
replace({
'process.env.BUGSNAG_API_KEY': JSON.stringify(process.env.BUGSNAG_API_KEY),
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
}),
typescript({ noEmitOnError: false }),
babel({
babelHelpers: 'bundled',
}),
nodeResolve({
browser: true,
}),
commonjs(),
],
output: [
{
dir: 'app',
format: 'cjs',
sourcemap: 'inline',
},
],
},
{
input: 'src/injected.ts',
plugins: [
json(),
replace({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
}),
typescript({ noEmitOnError: false }),
babel({
babelHelpers: 'bundled',
}),
nodeResolve({
browser: true,
}),
commonjs(),
],
output: [
{
dir: 'app',
format: 'iife',
sourcemap: 'inline',
},
],
},
{
external: [
...builtinModules,
...Object.keys(appManifest.dependencies),
...Object.keys(appManifest.devDependencies),
],
input: 'src/main.ts',
plugins: [
copy({
targets: [
{ src: 'src/public/*', dest: 'app' },
{ src: 'node_modules/@rocket.chat/icons/dist/*', dest: 'app/icons' },
],
}),
json(),
replace({
'process.env.BUGSNAG_API_KEY': JSON.stringify(process.env.BUGSNAG_API_KEY),
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
}),
typescript({ noEmitOnError: false }),
babel({
babelHelpers: 'bundled',
}),
nodeResolve(),
commonjs(),
run(),
],
output: {
dir: 'app',
format: 'cjs',
sourcemap: 'inline',
},
},
];
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。