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
821bedd9
Commit
821bedd9
authored
Oct 20, 2018
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `next export` read from .next/server to decide pathmap
parent
3640738f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
index.js
packages/next/export/index.js
+18
-4
No files found.
packages/next/export/index.js
View file @
821bedd9
...
@@ -8,6 +8,18 @@ import {PHASE_EXPORT, SERVER_DIRECTORY, PAGES_MANIFEST, CONFIG_FILE, BUILD_ID_FI
...
@@ -8,6 +8,18 @@ import {PHASE_EXPORT, SERVER_DIRECTORY, PAGES_MANIFEST, CONFIG_FILE, BUILD_ID_FI
import
{
renderToHTML
}
from
'next-server/dist/server/render'
import
{
renderToHTML
}
from
'next-server/dist/server/render'
import
{
setAssetPrefix
}
from
'next-server/asset'
import
{
setAssetPrefix
}
from
'next-server/asset'
import
*
as
envConfig
from
'next-server/config'
import
*
as
envConfig
from
'next-server/config'
import
globModule
from
'glob'
import
{
promisify
}
from
'util'
const
glob
=
promisify
(
globModule
)
function
normalizePageName
(
page
)
{
if
(
page
===
'index'
)
{
return
''
}
return
page
.
replace
(
/
(
^|
\/)
index$/
,
''
)
}
export
default
async
function
(
dir
,
options
,
configuration
)
{
export
default
async
function
(
dir
,
options
,
configuration
)
{
function
log
(
message
)
{
function
log
(
message
)
{
...
@@ -26,9 +38,11 @@ export default async function (dir, options, configuration) {
...
@@ -26,9 +38,11 @@ export default async function (dir, options, configuration) {
}
}
const
buildId
=
readFileSync
(
join
(
distDir
,
BUILD_ID_FILE
),
'utf8'
)
const
buildId
=
readFileSync
(
join
(
distDir
,
BUILD_ID_FILE
),
'utf8'
)
const
pagesManifest
=
require
(
join
(
distDir
,
SERVER_DIRECTORY
,
PAGES_MANIFEST
))
const
pages
=
Object
.
keys
(
pagesManifest
)
const
foundPages
=
await
glob
(
'**/*.js'
,
{
cwd
:
join
(
distDir
,
'server'
,
'pages'
)})
const
pages
=
foundPages
.
map
((
page
)
=>
{
return
'/'
+
normalizePageName
(
page
.
replace
(
/
\.
js$/
,
''
))
})
const
defaultPathMap
=
{}
const
defaultPathMap
=
{}
for
(
const
page
of
pages
)
{
for
(
const
page
of
pages
)
{
...
@@ -38,7 +52,7 @@ export default async function (dir, options, configuration) {
...
@@ -38,7 +52,7 @@ export default async function (dir, options, configuration) {
}
}
if
(
page
===
'/_error'
)
{
if
(
page
===
'/_error'
)
{
defaultPathMap
[
'/404'
]
=
{
page
}
defaultPathMap
[
'/404
.html
'
]
=
{
page
}
continue
continue
}
}
...
@@ -48,7 +62,7 @@ export default async function (dir, options, configuration) {
...
@@ -48,7 +62,7 @@ export default async function (dir, options, configuration) {
// Initialize the output directory
// Initialize the output directory
const
outDir
=
options
.
outdir
const
outDir
=
options
.
outdir
await
del
(
join
(
outDir
,
'*'
))
await
del
(
join
(
outDir
,
'*'
))
await
mkdirp
(
join
(
outDir
,
'_next'
,
buildId
))
await
mkdirp
(
join
(
outDir
,
'_next'
))
// Copy static directory
// Copy static directory
if
(
existsSync
(
join
(
dir
,
'static'
)))
{
if
(
existsSync
(
join
(
dir
,
'static'
)))
{
...
...
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