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
acc1983f
Commit
acc1983f
authored
Feb 14, 2017
by
Thomas Lindstrøm
Committed by
Guillermo Rauch
Feb 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't delete `.next` folder before a replacement is built (#1139)
parent
3766cd00
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
16 deletions
+38
-16
.gitignore
.gitignore
+2
-1
clean.js
server/build/clean.js
+2
-2
gzip.js
server/build/gzip.js
+2
-2
index.js
server/build/index.js
+11
-8
replace.js
server/build/replace.js
+18
-0
webpack.js
server/build/webpack.js
+2
-2
hot-reloader.js
server/hot-reloader.js
+1
-1
No files found.
.gitignore
View file @
acc1983f
...
...
@@ -9,6 +9,7 @@ npm-debug.log
# other
.next
.next-*
# coverage
.nyc_output
...
...
@@ -17,4 +18,4 @@ coverage
# editors
.idea/*
*.iml
*.sublime-*
\ No newline at end of file
*.sublime-*
server/build/clean.js
View file @
acc1983f
import
{
resolve
}
from
'path'
import
del
from
'del'
export
default
function
clean
(
dir
)
{
return
del
(
resolve
(
dir
,
'.next'
))
export
default
function
clean
(
dir
,
folderName
=
'.next'
)
{
return
del
(
resolve
(
dir
,
folderName
))
}
server/build/gzip.js
View file @
acc1983f
...
...
@@ -3,8 +3,8 @@ import path from 'path'
import
zlib
from
'zlib'
import
glob
from
'glob-promise'
export
default
async
function
gzipAssets
(
dir
)
{
const
nextDir
=
path
.
resolve
(
dir
,
'.next'
)
export
default
async
function
gzipAssets
(
dir
,
buildFolder
=
'.next'
)
{
const
nextDir
=
path
.
resolve
(
dir
,
buildFolder
)
const
coreAssets
=
[
path
.
join
(
nextDir
,
'commons.js'
),
...
...
server/build/index.js
View file @
acc1983f
...
...
@@ -4,16 +4,19 @@ import path from 'path'
import
webpack
from
'./webpack'
import
clean
from
'./clean'
import
gzipAssets
from
'./gzip'
import
replaceCurrentBuild
from
'./replace'
export
default
async
function
build
(
dir
)
{
const
[
compiler
]
=
await
Promise
.
all
([
webpack
(
dir
),
clean
(
dir
)
])
const
distFolder
=
'.next'
const
buildFolder
=
`.next-
${
uuid
.
v4
()}
`
const
compiler
=
await
webpack
(
dir
,
buildFolder
)
await
runCompiler
(
compiler
)
await
gzipAssets
(
dir
)
await
writeBuildId
(
dir
)
const
oldFolder
=
await
replaceCurrentBuild
(
dir
,
buildFolder
,
distFolder
)
await
gzipAssets
(
dir
,
distFolder
)
await
writeBuildId
(
dir
,
distFolder
)
clean
(
dir
,
oldFolder
)
}
function
runCompiler
(
compiler
)
{
...
...
@@ -34,8 +37,8 @@ function runCompiler (compiler) {
})
}
async
function
writeBuildId
(
dir
)
{
const
buildIdPath
=
path
.
resolve
(
dir
,
'.next'
,
'BUILD_ID'
)
async
function
writeBuildId
(
dir
,
distFolder
)
{
const
buildIdPath
=
path
.
resolve
(
dir
,
distFolder
,
'BUILD_ID'
)
const
buildId
=
uuid
.
v4
()
await
fs
.
writeFile
(
buildIdPath
,
buildId
,
'utf8'
)
}
server/build/replace.js
0 → 100644
View file @
acc1983f
import
fs
from
'fs'
import
path
from
'path'
import
uuid
from
'uuid'
export
default
function
replaceCurrentBuild
(
dir
,
buildFolder
,
distFolder
)
{
const
distDir
=
path
.
resolve
(
dir
,
distFolder
)
const
buildDir
=
path
.
resolve
(
dir
,
buildFolder
)
const
oldDir
=
path
.
resolve
(
dir
,
`.next-
${
uuid
.
v4
()}
`
)
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
rename
(
distDir
,
oldDir
,
()
=>
{
fs
.
rename
(
buildDir
,
distDir
,
(
err
)
=>
{
if
(
err
)
return
reject
(
err
)
resolve
(
oldDir
)
})
})
})
}
server/build/webpack.js
View file @
acc1983f
...
...
@@ -23,7 +23,7 @@ const interpolateNames = new Map(defaultPages.map((p) => {
return
[
join
(
nextPagesDir
,
p
),
`dist/pages/
${
p
}
`
]
}))
export
default
async
function
createCompiler
(
dir
,
{
dev
=
false
,
quiet
=
false
}
=
{})
{
export
default
async
function
createCompiler
(
dir
,
buildFolder
,
{
dev
=
false
,
quiet
=
false
}
=
{})
{
dir
=
resolve
(
dir
)
const
config
=
getConfig
(
dir
)
const
defaultEntries
=
dev
...
...
@@ -228,7 +228,7 @@ export default async function createCompiler (dir, { dev = false, quiet = false
context
:
dir
,
entry
,
output
:
{
path
:
join
(
dir
,
'.next'
),
path
:
join
(
dir
,
buildFolder
||
'.next'
),
filename
:
'[name]'
,
libraryTarget
:
'commonjs2'
,
publicPath
:
'/_webpack/'
,
...
...
server/hot-reloader.js
View file @
acc1983f
...
...
@@ -35,7 +35,7 @@ export default class HotReloader {
async
start
()
{
const
[
compiler
]
=
await
Promise
.
all
([
webpack
(
this
.
dir
,
{
dev
:
true
,
quiet
:
this
.
quiet
}),
webpack
(
this
.
dir
,
null
,
{
dev
:
true
,
quiet
:
this
.
quiet
}),
clean
(
this
.
dir
)
])
...
...
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