Skip to content

Serve Webpack DLL from Memory? #527

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

Closed
damassi opened this issue Jul 12, 2016 · 5 comments
Closed

Serve Webpack DLL from Memory? #527

damassi opened this issue Jul 12, 2016 · 5 comments

Comments

@damassi
Copy link

damassi commented Jul 12, 2016

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

@yanyu0517
Copy link

I meet the similar problem too. Is there any solutions?

@damassi
Copy link
Author

damassi commented Jul 27, 2016

@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.

@jhchill666
Copy link

jhchill666 commented Jul 28, 2016

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

@damassi
Copy link
Author

damassi commented Jul 28, 2016

Thats a fantastic solution -- will close this issue as it seems sufficient for most cases.

@damassi damassi closed this as completed Jul 28, 2016
@laurentvd
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants