Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
430789b9
Commit
430789b9
authored
May 11, 2017
by
Arunoda Susiripala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
By default print some messages to the console.
Also added a silent option if someone don't want those messages.
parent
d7048e13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
next-export
bin/next-export
+4
-4
export.js
server/export.js
+11
-3
No files found.
bin/next-export
View file @
430789b9
...
...
@@ -10,12 +10,12 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const
argv
=
parseArgs
(
process
.
argv
.
slice
(
2
),
{
alias
:
{
h
:
'help'
,
v
:
'verbose
'
,
s
:
'silent
'
,
o
:
'outdir'
},
boolean
:
[
'h'
],
default
:
{
v
:
false
,
s
:
false
,
o
:
null
}
})
...
...
@@ -34,8 +34,8 @@ if (argv.help) {
Options
-h - list this help
-v - run export with the verbose mode
-o - set the output dir (defaults to '.out')
-s - do not print any messages to console
`
)
process
.
exit
(
0
)
}
...
...
@@ -56,7 +56,7 @@ if (!existsSync(join(dir, 'pages'))) {
}
const
options
=
{
verbose
:
argv
.
verbose
,
silent
:
argv
.
silent
,
outdir
:
argv
.
outdir
?
resolve
(
argv
.
outdir
)
:
resolve
(
dir
,
'.out'
)
}
...
...
server/export.js
View file @
430789b9
...
...
@@ -13,6 +13,8 @@ export default async function (dir, options) {
const
outDir
=
options
.
outdir
const
nextDir
=
join
(
dir
,
'.next'
)
log
(
` Exporting to:
${
outDir
}
\n`
)
if
(
!
existsSync
(
nextDir
))
{
console
.
error
(
'Build your with "next build" before running "next start".'
)
process
.
exit
(
1
)
...
...
@@ -64,9 +66,7 @@ export default async function (dir, options) {
}
for
(
const
path
of
exportPaths
)
{
if
(
options
.
verbose
)
{
console
.
log
(
` exporing path:
${
path
}
`
)
}
log
(
` exporing path:
${
path
}
`
)
const
{
page
,
query
}
=
exportPathMap
[
path
]
const
req
=
{
url
:
path
}
...
...
@@ -81,6 +81,14 @@ export default async function (dir, options) {
const
html
=
await
renderToHTML
(
req
,
res
,
page
,
query
,
renderOpts
)
writeFileSync
(
htmlFilepath
,
html
,
'utf8'
)
}
// Add an empty line to the console for the better readability.
log
(
''
)
function
log
(
message
)
{
if
(
options
.
silent
)
return
console
.
log
(
message
)
}
}
function
copyPages
(
nextDir
,
outDir
,
buildId
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment