Skip to content

Commit

Permalink
support hot reload in examples again
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 3, 2016
1 parent c5e9c86 commit e874d06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion examples/server.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
const express = require('express')
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')
const webpackHotMiddleware = require('webpack-hot-middleware')
const WebpackConfig = require('./webpack.config')

const app = express()
const compiler = webpack(WebpackConfig)

app.use(webpackDevMiddleware(webpack(WebpackConfig), {
app.use(webpackDevMiddleware(compiler, {
publicPath: '/__build__/',
stats: {
colors: true,
chunks: false
}
}))

app.use(webpackHotMiddleware(compiler))

app.use(express.static(__dirname))

const port = process.env.PORT || 8080
Expand Down
7 changes: 5 additions & 2 deletions examples/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
const fullDir = path.join(__dirname, dir)
const entry = path.join(fullDir, 'app.js')
if (fs.statSync(fullDir).isDirectory() && fs.existsSync(entry)) {
entries[dir] = entry
entries[dir] = ['webpack-hot-middleware/client', entry]
}

return entries
Expand Down Expand Up @@ -40,7 +40,10 @@ module.exports = {
new webpack.optimize.CommonsChunkPlugin('shared.js'),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
})
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]

}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"vue": "^2.0.0-beta.5",
"vue-loader": "^9.0.3",
"webpack": "^1.12.8",
"webpack-dev-middleware": "^1.6.1"
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.12.2"
}
}

0 comments on commit e874d06

Please sign in to comment.