2016-03-28 66 views
1

你打算怎麼樣?我正面臨一個惱人的問題。我無法找到由html-webpack-plugin生成的index.html以便呈現它。我可以在localhost:8080/index.html上訪問它,但我不知道如何在帶有把手的路線上渲染它。由html webpack插件生成的渲染文件whithin路由器

我想要做什麼:在注射後找到我的視圖,並使用koa-views和handlebar進行渲染。

整個代碼:https://github.com/vini175pa/koa-redux-starterkit

路線:第一鏈接] /blob/master/server/routes/index.js

Webpack.config.js https://github.com/vini175pa/koa-redux-starterkit/blob/master/webpack.config.js

回答

1

也許你可以閱讀。

https://github.com/jantimon/html-webpack-plugin/issues/145

var express = require('express'); 
var app = express(); 
var webpack = require('webpack'); 
var path = require('path'); 

var compiler = webpack(require('./webpack.config.js')); 

app.use(require('webpack-dev-middleware')(compiler, { 
    noInfo: true, 
    publicPath: '/' 
})); 

app.use('*', function (req, res, next) { 
    var filename = path.join(compiler.outputPath,'index.html'); 
    compiler.outputFileSystem.readFile(filename, function(err, result){ 
    if (err) { 
     return next(err); 
    } 
    res.set('content-type','text/html'); 
    res.send(result); 
    res.end(); 
    }); 
}); 

app.listen(3000);