-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using webpack's html-webpack-plugin ~ fallback to cache memory? #2
Comments
@sunyang713 This middleware is meant to relay to |
I see, the intended usage for your middleware is to serve static files. I read your blog post and was convinced to adopt your principle of simplicity. I don't know that many people use the Here is the middleware code I ended up using as my solution: var app = express();
var compiler = webpack(webpackConfig);
. . .
// History API Fallback
app.get("*" function(req, res) {
var memoryFs = compiler.outputFileSystem;
var index = path.join(webpackConfig.output.path, "index.html");
var html = memoryFs.readFileSync(index);
res.end(html);
}); What do you think? I agree with what you said, to keep this simple and not fall into adding random features. EDIT: an additional note, I don't think this satisfies your requirements:
Maybe just putting the code inside a conditional |
@sunyang713's solution works fine. Just a heads up for people using this on Windows, |
🙇 Apologies for the late response. @sunyang713 Thanks for sharing. :) I'm not too familiar with the WebPack API so it looks a little scary to see a @Allov May want to pass the path through |
@CBas no worries, thanks for the response! I don't actually know if it blocks. It is coming from memory since it's webpack's internal API and not the regular 'readFileSync' method. I also have realized that this isn't exactly your issue. Here's an issue I posted on |
Hi, so I use webpack-dev-server, and I use a the html-webpack-plugin. As a result, the index.html is served from the cache memory along with the rest of the javscript files. How can I use your middleware to still handle hitting 'refresh' on
http://locahost:8080/some/route
?The text was updated successfully, but these errors were encountered: