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
8e9fe6f2
Commit
8e9fe6f2
authored
Mar 29, 2017
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update setup (get rid of html plugin)
parent
c4d3ab9d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
21 deletions
+12
-21
setup-dev-server.js
build/setup-dev-server.js
+3
-6
webpack.client.config.js
build/webpack.client.config.js
+0
-5
server.js
server.js
+9
-10
No files found.
build/setup-dev-server.js
View file @
8e9fe6f2
...
...
@@ -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
,
clientManifest
let
bundle
,
clientManifest
// modify client config to work with hot middleware
clientConfig
.
entry
.
app
=
[
'webpack-hot-middleware/client'
,
clientConfig
.
entry
.
app
]
...
...
@@ -25,11 +25,9 @@ module.exports = function setupDevServer (app, cb) {
clientCompiler
.
plugin
(
'done'
,
()
=>
{
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-client-manifest.json'
))
if
(
bundle
&&
serverManifest
)
{
if
(
bundle
)
{
cb
(
bundle
,
{
template
,
clientManifest
})
}
...
...
@@ -51,9 +49,8 @@ module.exports = function setupDevServer (app, cb) {
// read bundle generated by vue-ssr-webpack-plugin
bundle
=
JSON
.
parse
(
readFile
(
'vue-ssr-bundle.json'
))
if
(
template
&&
clientManifest
)
{
if
(
clientManifest
)
{
cb
(
bundle
,
{
template
,
clientManifest
})
}
...
...
build/webpack.client.config.js
View file @
8e9fe6f2
...
...
@@ -2,7 +2,6 @@ const webpack = require('webpack')
const
merge
=
require
(
'webpack-merge'
)
const
base
=
require
(
'./webpack.base.config'
)
const
vueConfig
=
require
(
'./vue-loader.config'
)
const
HTMLPlugin
=
require
(
'html-webpack-plugin'
)
const
SWPrecachePlugin
=
require
(
'sw-precache-webpack-plugin'
)
const
VueSSRClientPlugin
=
require
(
'vue-ssr-webpack-plugin'
).
client
...
...
@@ -32,10 +31,6 @@ const config = merge(base, {
new
webpack
.
optimize
.
CommonsChunkPlugin
({
name
:
'manifest'
}),
// generate output HTML
new
HTMLPlugin
({
template
:
'src/index.template.html'
}),
new
VueSSRClientPlugin
()
]
})
...
...
server.js
View file @
8e9fe6f2
...
...
@@ -13,9 +13,12 @@ const serverInfo =
const
app
=
express
()
const
template
=
fs
.
readFileSync
(
resolve
(
'./src/index.template.html'
),
'utf-8'
)
function
createRenderer
(
bundle
,
options
)
{
// https://github.com/vuejs/vue/blob/dev/packages/vue-server-renderer/README.md#why-use-bundlerenderer
return
createBundleRenderer
(
bundle
,
Object
.
assign
(
options
,
{
template
,
// for component caching
cache
:
require
(
'lru-cache'
)({
max
:
1000
,
...
...
@@ -29,19 +32,15 @@ function createRenderer (bundle, options) {
let
renderer
if
(
isProd
)
{
// In production: create server renderer using server bundle and index HTML
// template from real fs.
// In production: create server renderer using built server bundle.
// The server bundle is generated by vue-ssr-webpack-plugin.
const
bundle
=
require
(
'./dist/vue-ssr-bundle.json'
)
// src/index.template.html is processed by html-webpack-plugin to inject
// build assets and output as dist/index.html.
const
template
=
fs
.
readFileSync
(
resolve
(
'./dist/index.html'
),
'utf-8'
)
// 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.
const
clientManifest
=
require
(
'./dist/vue-ssr-client-manifest.json'
)
renderer
=
createRenderer
(
bundle
,
{
template
,
// 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.
clientManifest
:
require
(
'./dist/vue-ssr-client-manifest.json'
)
clientManifest
})
}
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