11import fs from 'fs'
22import path from 'path'
3- import { resolveConfig , UserConfig } from '../config'
3+ import { resolveConfig , UserConfig , ResolvedConfig } from '../config'
44import Rollup , { Plugin , RollupBuild , RollupOptions } from 'rollup'
55import { buildReporterPlugin } from '../plugins/reporter'
66import { buildDefinePlugin } from '../plugins/define'
@@ -149,21 +149,9 @@ export async function build(
149149 }
150150}
151151
152- async function doBuild (
153- inlineConfig : UserConfig & { mode ?: string } = { } ,
154- configPath ?: string | false
155- ) {
156- const mode = inlineConfig . mode || 'production'
157- const config = await resolveConfig ( inlineConfig , 'build' , mode , configPath )
152+ export function resolveBuildPlugins ( config : ResolvedConfig ) : Plugin [ ] {
158153 const options = config . build
159-
160- const resolve = ( p : string ) => path . resolve ( config . root , p )
161-
162- const input = options . rollupOptions ?. input || resolve ( 'index.html' )
163- const outDir = resolve ( options . outDir )
164- const publicDir = resolve ( 'public' )
165-
166- const plugins = [
154+ return [
167155 ...( config . plugins as Plugin [ ] ) ,
168156 ...( options . rollupOptions . plugins || [ ] ) ,
169157 buildHtmlPlugin ( config ) ,
@@ -179,6 +167,22 @@ async function doBuild(
179167 ...( options . manifest ? [ manifestPlugin ( ) ] : [ ] ) ,
180168 buildReporterPlugin ( config )
181169 ]
170+ }
171+
172+ async function doBuild (
173+ inlineConfig : UserConfig & { mode ?: string } = { } ,
174+ configPath ?: string | false
175+ ) {
176+ const mode = inlineConfig . mode || 'production'
177+ const config = await resolveConfig ( inlineConfig , 'build' , mode , configPath )
178+ const options = config . build
179+
180+ const resolve = ( p : string ) => path . resolve ( config . root , p )
181+
182+ const input = options . rollupOptions ?. input || resolve ( 'index.html' )
183+ const outDir = resolve ( options . outDir )
184+ const publicDir = resolve ( 'public' )
185+ const plugins = resolveBuildPlugins ( config )
182186
183187 const rollup = require ( 'rollup' ) as typeof Rollup
184188
0 commit comments