// app.js
require( "babel-polyfill" );
var webpack = require( 'webpack' )
var koaWebpack = require('koa-webpack');
var webpackConf = require( './webpack.config' )
var Koa = require( 'koa' )
var app = new Koa()
var compiler = webpack( webpackConf );
var middleware = koaWebpack({
compiler:compiler ,
dev:{
noInfo: false,
publicPath: webpackConf.output.publicPath
}
})
app.use( middleware )
app.use( ctx => {
console.log(middleware.dev.fileSystem);
const htmlBuffer = middleware.dev.fileSystem.readFileSync(`./index.html`);
ctx.type = 'html';
ctx.body = htmlBuffer;
} )
app.listen( 3000 );
Expected Behavior
just rebuild html files in stream but do not need press F5 when change index.html
Actual Behavior
get error
MemoryFileSystem { data: { home: { '': true, clyde: [Object] } } }
Error
at pathToArray (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/memory-fs/lib/MemoryFileSystem.js:44:10)
at MemoryFileSystem.readFileSync (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/memory-fs/lib/MemoryFileSystem.js:103:13)
at app.use.ctx (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/app.js:37:48)
at dispatch (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/koa-compose/index.js:44:32)
at next (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/koa-compose/index.js:45:18)
at dispatch (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/koa-compose/index.js:44:32)
at next (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/koa-compose/index.js:45:18)
at middleware (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/webpack-hot-middleware/middleware.js:26:48)
at _callee2$ (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/koa-webpack/dist/index.js:127:22)
at tryCatch (/home/clyde/Desktop/temp/ygm125/webpack/demo/webpack-hot-middleare/node_modules/regenerator-runtime/runtime.js:64:40)
Node Version: v7.7.3
NPM Version: 4.5.0
koa Version: 2.0.0
koa-wepback Version: 0.3.1
Expected Behavior
just rebuild html files in stream but do not need press F5 when change index.html
Actual Behavior
get error
How can we reproduce the behavior?
git clone https://github.com/dxcqcv/koa-demo.git then run
node app.js
in thatwebpack-hot-middleare/app.js:37