Open tandat2209 opened 8 years ago
same problem here. it doesnt happen when i run in production mode but, then i cant hot reload
Hi, i added the next code to the file server.js
app.get('*', function response(req, res) {
var extension = path.extname(req.url);
var name = req.url.split('/').pop();
switch (extension) {
case '.css':
res.setHeader("Content-Type", 'text/css');
res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
res.end();
break;
case '.png':
res.setHeader("Content-Type", 'image/png');
res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
res.end();
break;
case '.jpg':
res.setHeader("Content-Type", 'image/jpeg');
res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
res.end();
break;
default:
res.setHeader("Content-Type", 'text/html');
if (name == 'index.html') {
res.write(middleware.fileSystem.readFileSync(path.join(__dirname, 'dist/index.html')));
res.end();
} else {
fs.exists(path.join(__dirname, 'dist' + req.url), function (exists) {
console.log(exists);
if (exists) {
res.write(fs.readFileSync(path.join(__dirname, 'dist' + req.url)));
res.end();
}
});
}
break;
}
});
I don't know if it is related to this issue directly, but I had the same issue and it came out to be that I was reported by the devtools that the file was downloaded(code 200) but the actual content inside wasn't the file I expected(css
) rather an error message(html
).
When I put a link css to
index.tpl.html
I got this errorResource interpreted as Stylesheet but transferred with MIME type text/html: "..."
And I'm unable to use css.