Skip to content

Commit 3dec500

Browse files
authored
Add debug flag for extra build output (#16399)
This adds a `-d` or `--debug` flag which enables outputting additional build output information like the rewrites, redirects, and headers Fixes #15281
1 parent c210154 commit 3dec500

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

packages/next/build/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ export type PrerenderManifest = {
102102
export default async function build(
103103
dir: string,
104104
conf = null,
105-
reactProductionProfiling = false
105+
reactProductionProfiling = false,
106+
debugOutput = false
106107
): Promise<void> {
107108
if (!(await isWriteable(dir))) {
108109
throw new Error(
@@ -1024,7 +1025,10 @@ export default async function build(
10241025
isModern: config.experimental.modern,
10251026
}
10261027
)
1027-
printCustomRoutes({ redirects, rewrites, headers })
1028+
1029+
if (debugOutput) {
1030+
printCustomRoutes({ redirects, rewrites, headers })
1031+
}
10281032

10291033
if (tracer) {
10301034
const parsedResults = await tracer.profiler.stopProfiling()

packages/next/cli/next-build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ const nextBuild: cliCommand = (argv) => {
1212
// Types
1313
'--help': Boolean,
1414
'--profile': Boolean,
15+
'--debug': Boolean,
1516
// Aliases
1617
'-h': '--help',
18+
'-d': '--debug',
1719
}
1820

1921
let args: arg.Result<arg.Spec>
@@ -53,7 +55,7 @@ const nextBuild: cliCommand = (argv) => {
5355
printAndExit(`> No such directory exists as the project root: ${dir}`)
5456
}
5557

56-
build(dir, null, args['--profile'])
58+
build(dir, null, args['--profile'], args['--debug'])
5759
.then(() => process.exit(0))
5860
.catch((err) => {
5961
console.error('')

test/integration/custom-routes/test/index.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ const runTests = (isDev = false) => {
988988
})
989989
})
990990

991-
it('should have redirects/rewrites in build output', async () => {
991+
it('should have redirects/rewrites in build output with debug flag', async () => {
992992
const manifest = await fs.readJSON(
993993
join(appDir, '.next/routes-manifest.json')
994994
)
@@ -1073,7 +1073,7 @@ describe('Custom routes', () => {
10731073

10741074
describe('server mode', () => {
10751075
beforeAll(async () => {
1076-
const { stdout: buildStdout } = await nextBuild(appDir, [], {
1076+
const { stdout: buildStdout } = await nextBuild(appDir, ['-d'], {
10771077
stdout: true,
10781078
})
10791079
stdout = buildStdout
@@ -1093,7 +1093,7 @@ describe('Custom routes', () => {
10931093
nextConfigContent.replace(/\/\/ target/, 'target'),
10941094
'utf8'
10951095
)
1096-
const { stdout: buildStdout } = await nextBuild(appDir, [], {
1096+
const { stdout: buildStdout } = await nextBuild(appDir, ['-d'], {
10971097
stdout: true,
10981098
})
10991099
stdout = buildStdout

0 commit comments

Comments
 (0)