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
c4d3ab9d
Commit
c4d3ab9d
authored
Mar 29, 2017
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update setup per changes
parent
996266e4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
17 deletions
+7
-17
setup-dev-server.js
build/setup-dev-server.js
+4
-11
server.js
server.js
+3
-6
No files found.
build/setup-dev-server.js
View file @
c4d3ab9d
...
...
@@ -5,7 +5,7 @@ const clientConfig = require('./webpack.client.config')
const
serverConfig
=
require
(
'./webpack.server.config'
)
module
.
exports
=
function
setupDevServer
(
app
,
cb
)
{
let
bundle
,
template
,
serverManifest
,
clientManifest
let
bundle
,
template
,
clientManifest
// modify client config to work with hot middleware
clientConfig
.
entry
.
app
=
[
'webpack-hot-middleware/client'
,
clientConfig
.
entry
.
app
]
...
...
@@ -26,14 +26,11 @@ module.exports = function setupDevServer (app, cb) {
const
fs
=
devMiddleware
.
fileSystem
const
readFile
=
file
=>
fs
.
readFileSync
(
path
.
join
(
clientConfig
.
output
.
path
,
file
),
'utf-8'
)
template
=
readFile
(
'index.html'
)
clientManifest
=
JSON
.
parse
(
readFile
(
'vue-ssr-
manifest-clien
t.json'
))
clientManifest
=
JSON
.
parse
(
readFile
(
'vue-ssr-
client-manifes
t.json'
))
if
(
bundle
&&
serverManifest
)
{
cb
(
bundle
,
{
template
,
manifest
:
{
server
:
serverManifest
,
client
:
clientManifest
}
clientManifest
})
}
})
...
...
@@ -54,14 +51,10 @@ module.exports = function setupDevServer (app, cb) {
// read bundle generated by vue-ssr-webpack-plugin
bundle
=
JSON
.
parse
(
readFile
(
'vue-ssr-bundle.json'
))
serverManifest
=
JSON
.
parse
(
readFile
(
'vue-ssr-manifest-server.json'
))
if
(
template
&&
clientManifest
)
{
cb
(
bundle
,
{
template
,
manifest
:
{
server
:
serverManifest
,
client
:
clientManifest
}
clientManifest
})
}
})
...
...
server.js
View file @
c4d3ab9d
...
...
@@ -38,13 +38,10 @@ if (isProd) {
const
template
=
fs
.
readFileSync
(
resolve
(
'./dist/index.html'
),
'utf-8'
)
renderer
=
createRenderer
(
bundle
,
{
template
,
//
server and client manifests are optional, but they allow
the renderer
// to automatically
add
preload/prefetch links and directly add <script>
//
The client manifests are optional, but it allows
the renderer
// to automatically
infer
preload/prefetch links and directly add <script>
// tags for any async chunks used during render, avoiding waterfall requests.
manifest
:
{
server
:
require
(
'./dist/vue-ssr-manifest-server.json'
),
client
:
require
(
'./dist/vue-ssr-manifest-client.json'
)
}
clientManifest
:
require
(
'./dist/vue-ssr-client-manifest.json'
)
})
}
else
{
// In development: setup the dev server with watch and hot-reload,
...
...
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