Skip to content

Commit dbc0f04

Browse files
committed
Update to new version
1 parent f3ee4f1 commit dbc0f04

21 files changed

+227
-265
lines changed

.babelrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["es2015-webpack", "stage-2"]
3-
}
2+
"presets": [["es2015", { "modules": false }], "stage-2"],
3+
"ignore": ["node_modules/*"]
4+
}

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# vue-ssr-demo
1+
# vue-ssr-starter-kit
22

3-
> A Vue.js project with vue 2.0 and vue-router@next for server-side rendering.
3+
> A Vue.js project with vue 2.0, vue-router and vuex starter kit for server side rendering.
44
55
## Build Setup
66

@@ -15,4 +15,8 @@ npm start
1515
```bash
1616
npm install
1717
npm run dev
18-
```
18+
```
19+
20+
## License
21+
22+
[MIT](http://opensource.org/licenses/MIT)

build/dev-client.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

build/dev-server.js

Lines changed: 0 additions & 63 deletions
This file was deleted.

build/webpack.base.config.js

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
var path = require('path')
2-
var webpack = require('webpack')
1+
const path = require('path')
32

43
module.exports = {
4+
devtool: '#source-map',
55
entry: {
6-
app: './src/client-entry.js'
6+
app: './src/client-entry.js',
7+
vendor: ['vue', 'vue-router', 'vuex', 'vuex-router-sync', 'axios']
78
},
89
output: {
910
path: path.resolve(__dirname, '../dist'),
10-
publicPath: '/',
11+
publicPath: '/dist/',
1112
filename: 'client-bundle.js'
1213
},
13-
resolve: {
14-
extensions: ['', '.js', '.vue'],
15-
fallback: [path.join(__dirname, '../node_modules')],
16-
alias: {
17-
'src': path.resolve(__dirname, '../src'),
18-
'assets': path.resolve(__dirname, '../src/assets'),
19-
'components': path.resolve(__dirname, '../src/components')
20-
}
21-
},
2214
resolveLoader: {
23-
fallback: [path.join(__dirname, '../node_modules')]
15+
root: path.join(__dirname, '../node_modules'),
2416
},
2517
module: {
2618
loaders: [
@@ -33,10 +25,6 @@ module.exports = {
3325
loader: 'babel',
3426
exclude: /node_modules/
3527
},
36-
{
37-
test: /\.json$/,
38-
loader: 'json'
39-
},
4028
{
4129
test: /\.(png|jpg|gif|svg)$/,
4230
loader: 'file',
@@ -45,15 +33,5 @@ module.exports = {
4533
}
4634
}
4735
]
48-
},
49-
plugins: [
50-
new webpack.DefinePlugin({
51-
'process': {
52-
env: {
53-
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
54-
}
55-
}
56-
})
57-
],
58-
devtool: '#eval-source-map'
59-
}
36+
}
37+
}

build/webpack.client.config.js

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
1+
const base = require('./webpack.base.config')
12
const webpack = require('webpack')
2-
const merge = require('webpack-merge')
3-
const baseWebpackConfig = require('./webpack.base.config')
43

5-
webpackConfig = merge(baseWebpackConfig, {})
4+
const config = Object.assign({}, base, {
5+
plugins: [
6+
// strip comments in Vue code
7+
new webpack.DefinePlugin({
8+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
9+
}),
10+
// extract vendor chunks for better caching
11+
new webpack.optimize.CommonsChunkPlugin({
12+
name: 'vendor',
13+
filename: 'client-vendor-bundle.js'
14+
})
15+
]
16+
})
617

7-
// if (process.env.NODE_ENV === 'production') {
8-
// webpackConfig.devtool = '#source-map'
9-
// webpackConfig.plugins.push(
10-
// new webpack.optimize.UglifyJsPlugin({
11-
// compress: {
12-
// warnings: false
13-
// }
14-
// })
15-
// )
16-
// }
17-
module.exports = webpackConfig
18+
if (process.env.NODE_ENV === 'production') {
19+
// extract CSS into a single file so it's applied on initial render
20+
const ExtractTextPlugin = require('extract-text-webpack-plugin')
21+
22+
config.vue = {
23+
loaders: {
24+
css: ExtractTextPlugin.extract({
25+
loader: "css-loader",
26+
fallbackLoader: "vue-style-loader"
27+
})
28+
}
29+
}
30+
31+
config.plugins.push(
32+
new ExtractTextPlugin('styles.css'),
33+
// this is needed in webpack 2 for minifying CSS
34+
new webpack.LoaderOptionsPlugin({
35+
minimize: true
36+
}),
37+
// minify JS
38+
new webpack.optimize.UglifyJsPlugin({
39+
compress: {
40+
warnings: false
41+
}
42+
})
43+
)
44+
}
45+
46+
module.exports = config

build/webpack.dev.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

build/webpack.server.config.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
const webpack = require('webpack')
2-
const merge = require('webpack-merge')
3-
const baseWebpackConfig = require('./webpack.base.config')
2+
const base = require('./webpack.base.config')
43

5-
webpackConfig = merge(baseWebpackConfig, {
4+
module.exports = Object.assign({}, base, {
65
target: 'node',
7-
entry: {
8-
app: './src/server-entry.js'
9-
},
10-
output: {
6+
devtool: null,
7+
entry: './src/server-entry.js',
8+
output: Object.assign({}, base.output, {
119
filename: 'server-bundle.js',
1210
libraryTarget: 'commonjs2'
13-
},
11+
}),
12+
externals: ['axios'],
1413
plugins: [
1514
new webpack.DefinePlugin({
16-
'process': {
17-
env: {
18-
NODE_ENV: '"production"',
19-
VUE_ENV: '"server"'
20-
}
21-
}
15+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
16+
'process.env.VUE_ENV': '"server"'
2217
})
2318
]
2419
})
25-
26-
module.exports = webpackConfig

package.json

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
11
{
2-
"name": "vue-ssr-demo",
3-
"description": "A Vue.js project wuth vue 2.0 and vue-router@next for server-side rendering.",
2+
"name": "vue-ssr-starter-kit",
3+
"description": "A Vue.js project wuth vue 2.0, vue-router and vuex for server side rendering.",
44
"author": "doabit <[email protected]>",
55
"private": true,
66
"scripts": {
7-
"start": "node server",
8-
"dev": "nodemon --watch ./build ./build/dev-server.js",
9-
"build:client": "cross-env NODE_ENV=production webpack --config ./build/webpack.client.config.js",
10-
"build:server": "cross-env NODE_ENV=production webpack --config ./build/webpack.server.config.js",
11-
"build": "cross-env NODE_ENV=production webpack --config ./build/webpack.client.config.js && cross-env NODE_ENV=production webpack --config ./build/webpack.server.config.js"
7+
"start": "NODE_ENV=production node server",
8+
"dev": "node server",
9+
"build:client": "NODE_ENV=production webpack --config ./build/webpack.client.config.js --progress --hide-modules",
10+
"build:server": "NODE_ENV=production webpack --config ./build/webpack.server.config.js --progress --hide-modules",
11+
"build": "npm run build:client && npm run build:server"
1212
},
1313
"dependencies": {
1414
"axios": "^0.13.1",
15-
"body-parser": "^1.15.2",
1615
"express": "^4.14.0",
1716
"lru-cache": "^4.0.1",
1817
"serialize-javascript": "^1.3.0",
1918
"serve-favicon": "^2.3.0",
20-
"vue": "^2.0.0-beta.6",
21-
"vue-resource": "^0.9.3",
19+
"vue": "^2.0.0-beta.7",
2220
"vue-router": "^2.0.0-rc.1",
2321
"vue-server-renderer": "^2.0.0-beta.6",
24-
"vuex": "^2.0.0-rc.3"
22+
"vuex": "^2.0.0-rc.4",
23+
"vuex-router-sync": "^3.0.0"
2524
},
2625
"devDependencies": {
27-
"babel-core": "^6.0.0",
26+
"babel-core": "^6.13.2",
2827
"babel-loader": "^6.0.0",
29-
"babel-preset-es2015-webpack": "^6.0.0",
28+
"babel-preset-es2015": "^6.13.2",
3029
"babel-preset-stage-2": "^6.13.0",
31-
"cross-env": "^1.0.6",
3230
"css-loader": "^0.23.1",
31+
"extract-text-webpack-plugin": "^2.0.0-beta.3",
3332
"file-loader": "^0.8.4",
34-
"json-loader": "^0.5.4",
35-
"nodemon": "^1.10.0",
3633
"vue-loader": "^9.2.2",
3734
"webpack": "^2.1.0-beta.20",
38-
"webpack-dev-server": "^2.1.0-beta.0",
39-
"webpack-hot-middleware": "^2.12.2",
40-
"webpack-merge": "^0.14.1"
35+
"webpack-dev-middleware": "^1.6.1",
36+
"webpack-hot-middleware": "^2.12.2"
4137
}
4238
}

0 commit comments

Comments
 (0)