最近在项目中使用了webpack,感觉热加载这个特性很好用,但是由于是Node渲染,运行项目时要用node来跑,这个时候就用不了webpack的热加载了,因为webpack和node监听的是不同的端口。目前的做法是用gulp监听静态资源,有变化时执行webpack,打包静态资源到dist目录,同时更新html里引用的静态资源地址,但是每次打包都要3秒左右,而且还要手动刷新浏览器,感觉开发效率很低。想请教大家是怎么配置webpack做服务端渲染的项目的。
Have you seen this webpack-dev-middleware?
If you use express, you can integrate this middleware into your node application, it’s so high
express
node
Supplement:
There are examples on the website, as follows:
var webpackDevMiddleware = require("webpack-dev-middleware"); var webpack = require("webpack"); var compiler = webpack({ // configuration output: { path: '/' } }); app.use(webpackDevMiddleware(compiler, { // options }));
If you express play enough 6, the above code is clear and easy to understand
nodejs itself has hot loading, http://www.jianshu.com/p/ffc9...
Have you seen this webpack-dev-middleware?
If you use
express
, you can integrate this middleware into yournode
application, it’s so highSupplement:
There are examples on the website, as follows:
nodejs itself has hot loading, http://www.jianshu.com/p/ffc9...