mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
fix: rollup-plugin-esbuild 低版本报错
This commit is contained in:
parent
cbafc2c790
commit
48d5a92e6d
@ -6,6 +6,7 @@ import esbuild from 'rollup-plugin-esbuild'
|
||||
import alias from '@rollup/plugin-alias'
|
||||
import json from '@rollup/plugin-json'
|
||||
import copy from 'rollup-plugin-copy'
|
||||
import externals from 'rollup-plugin-node-externals'
|
||||
|
||||
export default (env = 'production') => {
|
||||
const options: RollupOptions = {
|
||||
@ -26,7 +27,7 @@ export default (env = 'production') => {
|
||||
exclude: /node_modules/, // default
|
||||
// watch: process.argv.includes('--watch'), // rollup 中有配置
|
||||
sourceMap: false, // default
|
||||
minify: process.env.NODE_ENV === 'production',
|
||||
minify: env === 'production',
|
||||
target: 'es2017', // default, or 'es20XX', 'esnext'
|
||||
jsxFactory: 'React.createElement',
|
||||
jsxFragment: 'React.Fragment',
|
||||
@ -34,6 +35,7 @@ export default (env = 'production') => {
|
||||
define: {
|
||||
__VERSION__: '"x.y.z"'
|
||||
},
|
||||
tsconfig: 'tsconfig.json', // default
|
||||
// Add extra loaders
|
||||
loaders: {
|
||||
// Add .json files support
|
||||
@ -50,21 +52,10 @@ export default (env = 'production') => {
|
||||
}),
|
||||
copy({
|
||||
targets: [{ src: join(__dirname, '../src/preload'), dest: join(__dirname, '../dist') }],
|
||||
})
|
||||
],
|
||||
external: [
|
||||
'crypto',
|
||||
'assert',
|
||||
'fs',
|
||||
'util',
|
||||
'os',
|
||||
'events',
|
||||
'child_process',
|
||||
'http',
|
||||
'https',
|
||||
'path',
|
||||
'electron',
|
||||
}),
|
||||
externals(),
|
||||
],
|
||||
external: ['electron'],
|
||||
}
|
||||
|
||||
return options
|
||||
|
@ -1,17 +1,19 @@
|
||||
import { get } from 'http'
|
||||
import { green } from 'chalk'
|
||||
|
||||
/** 轮询监听 vite 启动 */
|
||||
export function waitOn(arg0: { port: string | number; interval?: number; }) {
|
||||
return new Promise(resolve => {
|
||||
const { port, interval = 149 } = arg0
|
||||
const url = `http://localhost:${port}`
|
||||
let counter = 0
|
||||
const timer: NodeJS.Timer = setInterval(() => {
|
||||
get(`http://localhost:${port}`, res => {
|
||||
get(url, res => {
|
||||
clearInterval(timer)
|
||||
console.log('[waitOn]', res.statusCode, res.statusMessage)
|
||||
console.log('[waitOn]', green(`"${url}" are already responsive.`), `(${res.statusCode}: ${res.statusMessage})`)
|
||||
resolve(res.statusCode)
|
||||
}).on('error', err => {
|
||||
console.log('[waitOn]', `counter:${counter++}`)
|
||||
console.log('[waitOn]', `counter: ${counter++}`)
|
||||
})
|
||||
}, interval)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user