Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
880b7104
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
880b7104
编写于
11月 18, 2016
作者:
C
Chris Cunniff
提交者:
Naoyuki Kanezawa
11月 18, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #175, no longer sets process.env.NODE_ENV='production' or runs uglify in next dev mode (#274)
上级
e0455823
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
20 deletion
+29
-20
server/build/webpack.js
server/build/webpack.js
+25
-17
server/hot-reloader.js
server/hot-reloader.js
+3
-2
server/index.js
server/index.js
+1
-1
未找到文件。
server/build/webpack.js
浏览文件 @
880b7104
...
@@ -8,7 +8,7 @@ import WatchRemoveEventPlugin from './plugins/watch-remove-event-plugin'
...
@@ -8,7 +8,7 @@ import WatchRemoveEventPlugin from './plugins/watch-remove-event-plugin'
import
DynamicEntryPlugin
from
'
./plugins/dynamic-entry-plugin
'
import
DynamicEntryPlugin
from
'
./plugins/dynamic-entry-plugin
'
import
DetachPlugin
from
'
./plugins/detach-plugin
'
import
DetachPlugin
from
'
./plugins/detach-plugin
'
export
default
async
function
createCompiler
(
dir
,
{
hotReload
=
false
}
=
{})
{
export
default
async
function
createCompiler
(
dir
,
{
hotReload
=
false
,
dev
=
false
}
=
{})
{
dir
=
resolve
(
dir
)
dir
=
resolve
(
dir
)
const
pages
=
await
glob
(
'
pages/**/*.js
'
,
{
cwd
:
dir
})
const
pages
=
await
glob
(
'
pages/**/*.js
'
,
{
cwd
:
dir
})
...
@@ -34,28 +34,36 @@ export default async function createCompiler (dir, { hotReload = false } = {}) {
...
@@ -34,28 +34,36 @@ export default async function createCompiler (dir, { hotReload = false } = {}) {
const
nodeModulesDir
=
join
(
__dirname
,
'
..
'
,
'
..
'
,
'
..
'
,
'
node_modules
'
)
const
nodeModulesDir
=
join
(
__dirname
,
'
..
'
,
'
..
'
,
'
..
'
,
'
node_modules
'
)
const
plugins
=
[
const
plugins
=
[
new
webpack
.
DefinePlugin
({
'
process.env.NODE_ENV
'
:
JSON
.
stringify
(
'
production
'
)
}),
new
WriteFilePlugin
({
new
WriteFilePlugin
({
exitOnErrors
:
false
,
exitOnErrors
:
false
,
log
:
false
,
log
:
false
,
// required not to cache removed files
// required not to cache removed files
useHashIndex
:
false
useHashIndex
:
false
})
})
].
concat
(
hotReload
?
[
]
new
webpack
.
HotModuleReplacementPlugin
(),
new
DetachPlugin
(),
if
(
!
dev
)
{
new
DynamicEntryPlugin
(),
plugins
.
push
(
new
UnlinkFilePlugin
(),
new
webpack
.
DefinePlugin
({
new
WatchRemoveEventPlugin
(),
'
process.env.NODE_ENV
'
:
JSON
.
stringify
(
'
production
'
)
new
WatchPagesPlugin
(
dir
)
}),
]
:
[
new
webpack
.
optimize
.
UglifyJsPlugin
({
new
webpack
.
optimize
.
UglifyJsPlugin
({
compress
:
{
warnings
:
false
},
compress
:
{
warnings
:
false
},
sourceMap
:
false
sourceMap
:
false
})
})
)
])
}
if
(
hotReload
)
{
plugins
.
push
(
new
webpack
.
HotModuleReplacementPlugin
(),
new
DetachPlugin
(),
new
DynamicEntryPlugin
(),
new
UnlinkFilePlugin
(),
new
WatchRemoveEventPlugin
(),
new
WatchPagesPlugin
(
dir
)
)
}
const
babelRuntimePath
=
require
.
resolve
(
'
babel-runtime/package
'
)
const
babelRuntimePath
=
require
.
resolve
(
'
babel-runtime/package
'
)
.
replace
(
/
[\\\/]
package
\.
json$/
,
''
)
.
replace
(
/
[\\\/]
package
\.
json$/
,
''
)
...
...
server/hot-reloader.js
浏览文件 @
880b7104
...
@@ -4,8 +4,9 @@ import webpack from './build/webpack'
...
@@ -4,8 +4,9 @@ import webpack from './build/webpack'
import
read
from
'
./read
'
import
read
from
'
./read
'
export
default
class
HotReloader
{
export
default
class
HotReloader
{
constructor
(
dir
)
{
constructor
(
dir
,
dev
=
false
)
{
this
.
dir
=
dir
this
.
dir
=
dir
this
.
dev
=
dev
this
.
server
=
null
this
.
server
=
null
this
.
initialized
=
false
this
.
initialized
=
false
this
.
stats
=
null
this
.
stats
=
null
...
@@ -22,7 +23,7 @@ export default class HotReloader {
...
@@ -22,7 +23,7 @@ export default class HotReloader {
}
}
async
prepareServer
()
{
async
prepareServer
()
{
const
compiler
=
await
webpack
(
this
.
dir
,
{
hotReload
:
true
})
const
compiler
=
await
webpack
(
this
.
dir
,
{
hotReload
:
true
,
dev
:
this
.
dev
})
compiler
.
plugin
(
'
after-emit
'
,
(
compilation
,
callback
)
=>
{
compiler
.
plugin
(
'
after-emit
'
,
(
compilation
,
callback
)
=>
{
const
{
assets
}
=
compilation
const
{
assets
}
=
compilation
...
...
server/index.js
浏览文件 @
880b7104
...
@@ -11,7 +11,7 @@ export default class Server {
...
@@ -11,7 +11,7 @@ export default class Server {
constructor
({
dir
=
'
.
'
,
dev
=
false
,
hotReload
=
false
})
{
constructor
({
dir
=
'
.
'
,
dev
=
false
,
hotReload
=
false
})
{
this
.
dir
=
resolve
(
dir
)
this
.
dir
=
resolve
(
dir
)
this
.
dev
=
dev
this
.
dev
=
dev
this
.
hotReloader
=
hotReload
?
new
HotReloader
(
this
.
dir
)
:
null
this
.
hotReloader
=
hotReload
?
new
HotReloader
(
this
.
dir
,
this
.
dev
)
:
null
this
.
router
=
new
Router
()
this
.
router
=
new
Router
()
this
.
http
=
http
.
createServer
((
req
,
res
)
=>
{
this
.
http
=
http
.
createServer
((
req
,
res
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录