Our app has become fairly large and I'm trying to reduce the compile time by moving its vendor assets into a DLL. Right now we have it set up so that our .js is proxied through a Django app which serves assets from webpack-dev-server. This works great when everything is a single process and compiled from webpack.config.js and served from memory. However, when trying to setup webpack's DLL capabilities it requires a second webpack.vendors config to compile out the manifest into a file that sits on the file-system, and then webpack.config reads in that file when it does its thing. Since our app is proxied through Django and we have to use the full webpack-dev-server url (http://localhost:3000/static/) the vendors.js file is lost.
So my question is: is it possible to tell webpack-dev-server that my vendor dll exists and to serve it up in addition to the normal js content that is output from webpack.config.js?
Note: I'm following this example to create the DLL: https://gist.github.com/robertknight/058a194f45e77ff95fcd
I meet the similar problem too. Is there any solutions?
@yanyu0517 - This plugin solved my problem: https://github.com/gajus/write-file-webpack-plugin. Then, i just had to point my public path at the physical location and was able to get it to work. Note that it was a bit tricky, but it is resolvable.
If you're using express in front of webpack-dev-server, it's simply a case of adding a route to your Dll:
app.get(/dll.vendor.js$/, (req, res) => {
res.sendFile(`${config.paths.distDir}/js/dll.vendor.js`);
});
Obviously making sure you've built the Dll before starting up express
Thats a fantastic solution -- will close this issue as it seems sufficient for most cases.
You can tell it to serve existing files from disk by adding --content-base=./public/ to your webpack-dev-server command. This isn't obvious though.
Most helpful comment
You can tell it to serve existing files from disk by adding
--content-base=./public/to yourwebpack-dev-servercommand. This isn't obvious though.