mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-08-30 19:01:47 +08:00
chore: update
This commit is contained in:
@@ -35,6 +35,8 @@ if (argv.watch) {
|
||||
if (ev.code === 'END') {
|
||||
// init-未启动、started-第一次启动、restarted-重新启动
|
||||
electron.electronState === 'init' ? electron.start() : electron.restart();
|
||||
} else if (ev.code === 'ERROR') {
|
||||
console.log(ev.error)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -1,27 +1,44 @@
|
||||
const path = require('path');
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
||||
const commonjs = require('@rollup/plugin-commonjs');
|
||||
const typescript = require('@rollup/plugin-typescript');
|
||||
const path = require('path')
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
||||
const commonjs = require('@rollup/plugin-commonjs')
|
||||
const esbuild = require('rollup-plugin-esbuild')
|
||||
|
||||
module.exports = (env = 'production') => {
|
||||
return {
|
||||
input: path.join(__dirname, '../src/main/index.ts'),
|
||||
output: {
|
||||
file: path.join(__dirname, '../src/main/_.js'),
|
||||
file: path.join(__dirname, '../dist/main/_.js'),
|
||||
format: 'cjs',
|
||||
name: 'ElectronMainBundle',
|
||||
sourcemap: true,
|
||||
},
|
||||
plugins: [
|
||||
nodeResolve({ jsnext: true, preferBuiltins: true, browser: true }), // 消除碰到 node.js 模块时⚠警告
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
typescript(),
|
||||
],
|
||||
external: [
|
||||
'fs',
|
||||
'path',
|
||||
'electron',
|
||||
'electron-is-dev',
|
||||
esbuild({
|
||||
// All options are optional
|
||||
include: /\.[jt]sx?$/, // default, inferred from `loaders` option
|
||||
exclude: /node_modules/, // default
|
||||
// watch: process.argv.includes('--watch'), // rollup 中有配置
|
||||
sourceMap: false, // default
|
||||
minify: process.env.NODE_ENV === 'production',
|
||||
target: 'es2017', // default, or 'es20XX', 'esnext'
|
||||
jsxFactory: 'React.createElement',
|
||||
jsxFragment: 'React.Fragment',
|
||||
// Like @rollup/plugin-replace
|
||||
define: {
|
||||
__VERSION__: '"x.y.z"'
|
||||
},
|
||||
// Add extra loaders
|
||||
loaders: {
|
||||
// Add .json files support
|
||||
// require @rollup/plugin-commonjs
|
||||
'.json': 'json',
|
||||
// Enable JSX in .js files too
|
||||
'.js': 'jsx'
|
||||
}
|
||||
}),
|
||||
],
|
||||
external: ['fs', 'path', 'electron', 'electron-is-dev'],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user