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:
parent
71296cceb3
commit
42f1d2efda
|
@ -10,11 +10,13 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
alias: {
|
alias: {
|
||||||
h: 'help',
|
h: 'help',
|
||||||
v: 'verbose'
|
v: 'verbose',
|
||||||
|
o: 'outdir'
|
||||||
},
|
},
|
||||||
boolean: ['h'],
|
boolean: ['h'],
|
||||||
default: {
|
default: {
|
||||||
v: false
|
v: false,
|
||||||
|
o: null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -24,11 +26,16 @@ if (argv.help) {
|
||||||
Exports the application for production deployment
|
Exports the application for production deployment
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
$ next export <dir>
|
$ next export [options] <dir>
|
||||||
|
|
||||||
<dir> represents where the compiled dist folder should go.
|
<dir> represents where the compiled dist folder should go.
|
||||||
If no directory is provided, the dist folder will be created in the current directory.
|
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'
|
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)
|
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')
|
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) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { printAndExit } from '../lib/utils'
|
||||||
|
|
||||||
export default async function (dir, options) {
|
export default async function (dir, options) {
|
||||||
dir = resolve(dir)
|
dir = resolve(dir)
|
||||||
const outDir = join(dir, '.out')
|
const outDir = options.outdir
|
||||||
const nextDir = join(dir, '.next')
|
const nextDir = join(dir, '.next')
|
||||||
|
|
||||||
if (!existsSync(nextDir)) {
|
if (!existsSync(nextDir)) {
|
||||||
|
|
Loading…
Reference in a new issue