Skip to content

Commit 42f1d2e

Browse files
committed
Add a way to customize the output directory.
1 parent 71296cc commit 42f1d2e

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

bin/next-export

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
1010
const argv = parseArgs(process.argv.slice(2), {
1111
alias: {
1212
h: 'help',
13-
v: 'verbose'
13+
v: 'verbose',
14+
o: 'outdir'
1415
},
1516
boolean: ['h'],
1617
default: {
17-
v: false
18+
v: false,
19+
o: null
1820
}
1921
})
2022

@@ -24,11 +26,16 @@ if (argv.help) {
2426
Exports the application for production deployment
2527
2628
Usage
27-
$ next export <dir>
29+
$ next export [options] <dir>
2830
2931
<dir> represents where the compiled dist folder should go.
3032
If no directory is provided, the dist folder will be created in the current directory.
3133
You can set a custom folder in config https://github.com/zeit/next.js#custom-configuration, otherwise it will be created inside '.next'
34+
35+
Options
36+
-h - list this help
37+
-v - run export with the verbose mode
38+
-o - set the output dir (defaults to '.out')
3239
`)
3340
process.exit(0)
3441
}
@@ -48,7 +55,12 @@ if (!existsSync(join(dir, 'pages'))) {
4855
printAndExit('> Couldn\'t find a `pages` directory. Please create one under the project root')
4956
}
5057

51-
exportApp(dir, { verbose: argv.verbose })
58+
const options = {
59+
verbose: argv.verbose,
60+
outdir: argv.outdir ? resolve(argv.outdir) : resolve(dir, '.out')
61+
}
62+
63+
exportApp(dir, options)
5264
.catch((err) => {
5365
console.error(err)
5466
process.exit(1)

server/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { printAndExit } from '../lib/utils'
99

1010
export default async function (dir, options) {
1111
dir = resolve(dir)
12-
const outDir = join(dir, '.out')
12+
const outDir = options.outdir
1313
const nextDir = join(dir, '.next')
1414

1515
if (!existsSync(nextDir)) {

0 commit comments

Comments
 (0)