Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
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
周韬
node-sample
Commits
f7669ef0
Commit
f7669ef0
authored
May 12, 2017
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve dev server compile error handling
parent
4537fdd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
setup-dev-server.js
build/setup-dev-server.js
+18
-8
No files found.
build/setup-dev-server.js
View file @
f7669ef0
...
...
@@ -4,6 +4,12 @@ const MFS = require('memory-fs')
const
clientConfig
=
require
(
'./webpack.client.config'
)
const
serverConfig
=
require
(
'./webpack.server.config'
)
const
readFile
=
(
fs
,
file
)
=>
{
try
{
return
fs
.
readFileSync
(
path
.
join
(
clientConfig
.
output
.
path
,
file
),
'utf-8'
)
}
catch
(
e
)
{}
}
module
.
exports
=
function
setupDevServer
(
app
,
cb
)
{
let
bundle
,
clientManifest
let
resolve
...
...
@@ -28,10 +34,16 @@ module.exports = function setupDevServer (app, cb) {
noInfo
:
true
})
app
.
use
(
devMiddleware
)
clientCompiler
.
plugin
(
'done'
,
()
=>
{
const
fs
=
devMiddleware
.
fileSystem
const
readFile
=
file
=>
fs
.
readFileSync
(
path
.
join
(
clientConfig
.
output
.
path
,
file
),
'utf-8'
)
clientManifest
=
JSON
.
parse
(
readFile
(
'vue-ssr-client-manifest.json'
))
clientCompiler
.
plugin
(
'done'
,
stats
=>
{
stats
=
stats
.
toJson
()
stats
.
errors
.
forEach
(
err
=>
console
.
error
(
err
))
stats
.
warnings
.
forEach
(
err
=>
console
.
warn
(
err
))
if
(
stats
.
errors
.
length
)
return
clientManifest
=
JSON
.
parse
(
readFile
(
devMiddleware
.
fileSystem
,
'vue-ssr-client-manifest.json'
))
if
(
bundle
)
{
ready
(
bundle
,
{
clientManifest
...
...
@@ -49,12 +61,10 @@ module.exports = function setupDevServer (app, cb) {
serverCompiler
.
watch
({},
(
err
,
stats
)
=>
{
if
(
err
)
throw
err
stats
=
stats
.
toJson
()
stats
.
errors
.
forEach
(
err
=>
console
.
error
(
err
))
stats
.
warnings
.
forEach
(
err
=>
console
.
warn
(
err
))
const
readFile
=
file
=>
mfs
.
readFileSync
(
path
.
join
(
clientConfig
.
output
.
path
,
file
),
'utf-8'
)
if
(
stats
.
errors
.
length
)
return
// read bundle generated by vue-ssr-webpack-plugin
bundle
=
JSON
.
parse
(
readFile
(
'vue-ssr-server-bundle.json'
))
bundle
=
JSON
.
parse
(
readFile
(
mfs
,
'vue-ssr-server-bundle.json'
))
if
(
clientManifest
)
{
ready
(
bundle
,
{
clientManifest
...
...
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