@@ -29,6 +29,7 @@ import { CleanCSS } from 'types/clean-css'
29
29
import { dataURIPlugin } from './plugins/dataUri'
30
30
import { buildImportAnalysisPlugin } from './plugins/importAnaysisBuild'
31
31
import { resolveSSRExternal } from './ssr/ssrExternal'
32
+ import { ssrManifestPlugin } from './ssr/ssrManifestPlugin'
32
33
33
34
export interface BuildOptions {
34
35
/**
@@ -148,9 +149,15 @@ export interface BuildOptions {
148
149
*/
149
150
lib ?: LibraryOptions | false
150
151
/**
151
- * @internal for now
152
+ * Produce SSR oriented build. Note this requires specifying SSR entry via
153
+ * `rollupOptions.input`.
152
154
*/
153
155
ssr ?: boolean
156
+ /**
157
+ * Generate SSR manifest for determining style links and asset preload
158
+ * directives in production.
159
+ */
160
+ ssrManifest ?: boolean
154
161
}
155
162
156
163
export interface LibraryOptions {
@@ -187,6 +194,7 @@ export function resolveBuildOptions(
187
194
manifest : false ,
188
195
lib : false ,
189
196
ssr : false ,
197
+ ssrManifest : false ,
190
198
...raw
191
199
}
192
200
@@ -233,6 +241,7 @@ export function resolveBuildPlugins(
233
241
? [ terserPlugin ( options . terserOptions ) ]
234
242
: [ ] ) ,
235
243
...( options . manifest ? [ manifestPlugin ( ) ] : [ ] ) ,
244
+ ...( options . ssrManifest ? [ ssrManifestPlugin ( config ) ] : [ ] ) ,
236
245
...( ! config . logLevel || config . logLevel === 'info'
237
246
? [ buildReporterPlugin ( config ) ]
238
247
: [ ] )
@@ -272,13 +281,15 @@ async function doBuild(
272
281
inlineConfig : InlineConfig = { }
273
282
) : Promise < RollupOutput | RollupOutput [ ] > {
274
283
const config = await resolveConfig ( inlineConfig , 'build' , 'production' )
275
- config . logger . info ( chalk . cyan ( `building for ${ config . mode } ...` ) )
276
-
277
284
const options = config . build
278
285
const ssr = ! ! options . ssr
279
286
const libOptions = options . lib
280
- const resolve = ( p : string ) => path . resolve ( config . root , p )
281
287
288
+ config . logger . info (
289
+ chalk . cyan ( `building ${ ssr ? `SSR bundle ` : `` } for ${ config . mode } ...` )
290
+ )
291
+
292
+ const resolve = ( p : string ) => path . resolve ( config . root , p )
282
293
const input = libOptions
283
294
? libOptions . entry
284
295
: options . rollupOptions ?. input || resolve ( 'index.html' )
@@ -351,6 +362,7 @@ async function doBuild(
351
362
// #764 add `Symbol.toStringTag` when build es module into cjs chunk
352
363
// #1048 add `Symbol.toStringTag` for module default export
353
364
namespaceToStringTag : true ,
365
+ inlineDynamicImports : ssr && typeof input === 'string' ,
354
366
...output
355
367
} )
356
368
}
0 commit comments