Skip to content

Commit e526e08

Browse files
author
linhs
committed
完成 ssr 课程章节 5-1,但是内容尚需消化
1 parent 5508025 commit e526e08

File tree

8 files changed

+139
-88
lines changed

8 files changed

+139
-88
lines changed

build/webpack.config.client.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const HtmlPlugin = require('html-webpack-plugin');
77
// 将非 JS 的文件单独打包分离出来,这里主要是希望单独引入 CSS
88
const ExtractPlugin = require('extract-text-webpack-plugin');
99
const baseConfig = require('./webpack.config.base');
10+
11+
const VueClientPlugin = require('vue-server-renderer/client-plugin');
1012
// windows npm script 设置变量是通过 set NODE_ENV=production
1113
// mac npm script 设置变量是 NODE_ENV=production NODE_ENV=production
1214
// 使用 cross-env 可以统一设置环境变量的方式: cross-env
@@ -22,6 +24,7 @@ const defaultPlugins = [
2224
new HtmlPlugin({
2325
template: path.join(__dirname, 'template.html')
2426
}),
27+
new VueClientPlugin(),
2528
];
2629

2730
const devServer = { // 支持热更新

build/webpack.config.server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const config = webpackMerge(baseConfig, {
2121
filename: 'server-entry.js',
2222
path: path.join(__dirname, '../server-build'),
2323
},
24+
// 纯前端渲染就需要把类库连同你的代码一起打包,因为浏览器没有 module 模块
2425
// 不要打包 vue, vuex, vue-router 到 node
2526
// 因为如果打包了,就跟 node_modules 里面的依赖有重复,造成打包了两份文件
2627
externals: Object.keys(require('../package.json').dependencies),

0 commit comments

Comments
 (0)