mirror of
https://github.com/alex8088/electron-vite.git
synced 2026-11-02 06:42:22 +08:00
refactor: inline bytecode build plugin name
This commit is contained in:
parent
6fc103eb5b
commit
0655933704
@ -1,7 +1,6 @@
|
||||
import { build as viteBuild, mergeConfig } from 'vite'
|
||||
import { type InlineConfig, type MainViteConfig, type PreloadViteConfig, resolveConfig } from './config'
|
||||
import { BytecodeCompiler } from './bytecodeCompiler'
|
||||
import { BYTECODE_BUILD_PLUGIN_NAME } from './constants'
|
||||
import { asyncFlatten } from './utils'
|
||||
|
||||
async function usesBytecode(config?: MainViteConfig | PreloadViteConfig): Promise<boolean> {
|
||||
@ -20,7 +19,7 @@ export async function build(inlineConfig: InlineConfig = {}): Promise<void> {
|
||||
const bytecodeCompiler = new BytecodeCompiler()
|
||||
const config = await resolveConfig(
|
||||
mergeConfig(inlineConfig, {
|
||||
plugins: [{ name: BYTECODE_BUILD_PLUGIN_NAME, api: { compiler: bytecodeCompiler } }]
|
||||
plugins: [{ name: 'vite:electron-bytecode-build', api: { compiler: bytecodeCompiler } }]
|
||||
}),
|
||||
'build',
|
||||
'production'
|
||||
|
||||
@ -1 +0,0 @@
|
||||
export const BYTECODE_BUILD_PLUGIN_NAME = 'vite:electron-bytecode-build'
|
||||
@ -6,12 +6,11 @@ import * as babel from '@babel/core'
|
||||
import MagicString from 'magic-string'
|
||||
import { toRelativePath } from '../utils'
|
||||
import type { BytecodeCompiler, BytecodeTarget } from '../bytecodeCompiler'
|
||||
import { BYTECODE_BUILD_PLUGIN_NAME } from '../constants'
|
||||
|
||||
// Inspired by https://github.com/bytenode/bytenode
|
||||
|
||||
function getBytecodeCompiler(plugins: readonly Plugin[]): BytecodeCompiler | undefined {
|
||||
const plugin = plugins.find(plugin => plugin.name === BYTECODE_BUILD_PLUGIN_NAME)
|
||||
const plugin = plugins.find(plugin => plugin.name === 'vite:electron-bytecode-build')
|
||||
return (plugin?.api as { compiler?: BytecodeCompiler } | undefined)?.compiler
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user