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
da2bb321
Commit
da2bb321
authored
Oct 23, 2018
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make old builder a proxy
parent
59c5333a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
62 deletions
+1
-62
index.js
packages/next/build/index.js
+1
-62
No files found.
packages/next/build/index.js
View file @
da2bb321
import
{
join
}
from
'path'
module
.
exports
=
require
(
'next-build'
)
import
promisify
from
'../lib/promisify'
import
fs
from
'fs'
import
webpack
from
'webpack'
import
loadConfig
from
'next-server/next-config'
import
{
PHASE_PRODUCTION_BUILD
,
BUILD_ID_FILE
}
from
'next-server/constants'
import
getBaseWebpackConfig
from
'./webpack'
const
access
=
promisify
(
fs
.
access
)
const
writeFile
=
promisify
(
fs
.
writeFile
)
export
default
async
function
build
({
dir
,
conf
=
null
,
pages
})
{
const
config
=
loadConfig
(
PHASE_PRODUCTION_BUILD
,
dir
,
conf
)
const
buildId
=
await
config
.
generateBuildId
().
trim
()
// defaults to a uuid
const
distDir
=
join
(
dir
,
config
.
distDir
)
try
{
await
access
(
dir
,
(
fs
.
constants
||
fs
).
W_OK
)
}
catch
(
err
)
{
console
.
error
(
`> Failed, build directory is not writeable. https://err.sh/zeit/next.js/build-dir-not-writeable`
)
throw
err
}
try
{
const
configs
=
await
Promise
.
all
([
getBaseWebpackConfig
(
dir
,
{
pages
,
buildId
,
isServer
:
false
,
config
}),
getBaseWebpackConfig
(
dir
,
{
pages
,
buildId
,
isServer
:
true
,
config
})
])
await
runCompiler
(
configs
)
await
writeBuildId
(
distDir
,
buildId
)
}
catch
(
err
)
{
console
.
error
(
`> Failed to build`
)
throw
err
}
}
function
runCompiler
(
compiler
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
webpackCompiler
=
await
webpack
(
await
compiler
)
webpackCompiler
.
run
((
err
,
stats
)
=>
{
if
(
err
)
return
reject
(
err
)
const
jsonStats
=
stats
.
toJson
(
'errors-only'
)
if
(
jsonStats
.
errors
.
length
>
0
)
{
const
error
=
new
Error
(
jsonStats
.
errors
[
0
])
error
.
errors
=
jsonStats
.
errors
error
.
warnings
=
jsonStats
.
warnings
return
reject
(
error
)
}
resolve
()
})
})
}
async
function
writeBuildId
(
distDir
,
buildId
)
{
const
buildIdPath
=
join
(
distDir
,
BUILD_ID_FILE
)
await
writeFile
(
buildIdPath
,
buildId
,
'utf8'
)
}
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