1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Add a way to customize the output directory.

This commit is contained in:
Arunoda Susiripala 2017-05-08 19:10:55 -07:00
parent 71296cceb3
commit 42f1d2efda
2 changed files with 17 additions and 5 deletions

View file

@ -10,11 +10,13 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const argv = parseArgs(process.argv.slice(2), {
alias: {
h: 'help',
v: 'verbose'
v: 'verbose',
o: 'outdir'
},
boolean: ['h'],
default: {
v: false
v: false,
o: null
}
})
@ -24,11 +26,16 @@ if (argv.help) {
Exports the application for production deployment
Usage
$ next export <dir>
$ next export [options] <dir>
<dir> represents where the compiled dist folder should go.
If no directory is provided, the dist folder will be created in the current directory.
You can set a custom folder in config https://github.com/zeit/next.js#custom-configuration, otherwise it will be created inside '.next'
Options
-h - list this help
-v - run export with the verbose mode
-o - set the output dir (defaults to '.out')
`)
process.exit(0)
}
@ -48,7 +55,12 @@ if (!existsSync(join(dir, 'pages'))) {
printAndExit('> Couldn\'t find a `pages` directory. Please create one under the project root')
}
exportApp(dir, { verbose: argv.verbose })
const options = {
verbose: argv.verbose,
outdir: argv.outdir ? resolve(argv.outdir) : resolve(dir, '.out')
}
exportApp(dir, options)
.catch((err) => {
console.error(err)
process.exit(1)

View file

@ -9,7 +9,7 @@ import { printAndExit } from '../lib/utils'
export default async function (dir, options) {
dir = resolve(dir)
const outDir = join(dir, '.out')
const outDir = options.outdir
const nextDir = join(dir, '.next')
if (!existsSync(nextDir)) {