@@ -2,6 +2,9 @@ import { test } from 'uvu';
22import * as assert from 'uvu/assert' ;
33
44import { setupTest , teardownTest , loadFixture , viteBuildCli } from './lib/lifecycle.js' ;
5+ import { writeFixtureFile } from './lib/utils.js' ;
6+
7+ const writeConfig = async ( dir , content ) => writeFixtureFile ( dir , 'vite.config.js' , content ) ;
58
69let env ;
710test . before . each ( async ( ) => {
@@ -12,19 +15,45 @@ test.after.each(async () => {
1215 await teardownTest ( env ) ;
1316} ) ;
1417
15- test ( 'Should support the `prerenderScript` plugin option ' , async ( ) => {
18+ test ( 'Should log which routes were prerendered & where they were discovered ' , async ( ) => {
1619 await loadFixture ( 'logs/prerendered-routes' , env ) ;
1720 const output = await viteBuildCli ( env . tmp . path ) ;
1821 await output . done ;
1922
20- const idx = output . stdout . findIndex ( ( line ) => line . includes ( 'Prerendered' ) ) ;
2123 // The prerender info is pushed as a single log line
22- const stdout = output . stdout . slice ( idx ) [ 0 ] ;
24+ const stdout = output . stdout . find ( ( line ) => line . includes ( 'Prerendered' ) ) ;
2325
2426 assert . match ( stdout , 'Prerendered 3 pages:\n' ) ;
2527 assert . match ( stdout , '/\n' ) ;
2628 assert . match ( stdout , '/foo [from /]\n' ) ;
2729 assert . match ( stdout , '/bar [from /foo]\n' ) ;
2830} ) ;
2931
32+ test ( 'Should strip sourcemap sizes from logs if user has not enabled sourcemaps' , async ( ) => {
33+ await loadFixture ( 'logs/prerendered-routes' , env ) ;
34+ const output = await viteBuildCli ( env . tmp . path ) ;
35+ await output . done ;
36+
37+ const stdout = output . stdout . find ( ( line ) => / d i s t \/ a s s e t s \/ i n d e x .* \. j s / . test ( line ) ) ;
38+ assert . not . match ( stdout , '│ map:' ) ;
39+ } ) ;
40+
41+ test ( 'Should preserve sourcemap sizes from logs if user has enabled sourcemaps' , async ( ) => {
42+ await loadFixture ( 'logs/prerendered-routes' , env ) ;
43+ await writeConfig ( env . tmp . path , `
44+ import { defineConfig } from 'vite';
45+ import { vitePrerenderPlugin } from 'vite-prerender-plugin';
46+
47+ export default defineConfig({
48+ build: { sourcemap: true },
49+ plugins: [vitePrerenderPlugin()],
50+ });
51+ ` ) ;
52+ const output = await viteBuildCli ( env . tmp . path ) ;
53+ await output . done ;
54+
55+ const stdout = output . stdout . find ( ( line ) => / d i s t \/ a s s e t s \/ i n d e x .* \. j s / . test ( line ) ) ;
56+ assert . match ( stdout , '│ map:' ) ;
57+ } ) ;
58+
3059test . run ( ) ;
0 commit comments