nickjj / manifest-revision-webpack-plugin

Write out a manifest file containing your versioned webpack chunks and assets.
ISC License
124 stars 40 forks source link

Add support for adding assets from CDN #13

Closed ziogaschr closed 8 years ago

ziogaschr commented 8 years ago

It will be nice if I can set all the dependencies on the webpack config file, instead of having to handle this in my Server side code.

For example I am using the flask-webpack plugin so as my webpack packaged files are being loaded to the flask app. At the moment, in the Flask app I have added a script tag that loads jQuery from CDN and then in the webpack config file I add it to the externals so as I can use it in the code. Although this makes me to have to update the code in two places.

Wouldn't be great if I can add a list of full URLs to be added in the manifest file, and then having flask-webpack or other similar plugins parse it from there?

nickjj commented 8 years ago

My concern is this isn't really a responsibility of this plugin but I am not opposed to the general idea.

What you could do for now is pass in a custom function reporter (just copy/paste the default one and modify it to do what you want). This wouldn't require forking this plugin. I'd be curious to see what you come up with.

ziogaschr commented 8 years ago

I thought the same at the begging, although this plugin is the only one which can talk with my Flask app.

I will try to do what you suggest this week, thanks.

nickjj commented 8 years ago

Yeah I currently just enter in the CDN addresses in my server side templates.

Although if you use a CDN locally you can configure webpack to use that so your URLs are configured with the CDN address automatically.

This project is configured to do this: https://github.com/nickjj/build-a-saas-app-with-flask (check the config/ folder as well as the Dockerfile which is where the assets get built).

Also I do want to point out the flask-webpack template tags do understand URLs. If you dropped in the jquery CDN URL instead of passing in an asset name, it knows to use the URL straight up with the javascript_tag helper.

ziogaschr commented 8 years ago

Thanks a lot for your quick responses.

Indeed, if everything is served from same location (CDN) all is fine, but what happens if I prefer to use another location (CDN) for some libraries? e.g. jQuery.

Thanks for you note that the javascript_tag helper already understands full URLs, haven't checked this yet ;)

nickjj commented 8 years ago

Going to close this. Sorry I missed your last reply for so long. In the case where you want to use multiple CDNs (ie. jQuery), the javascript_tag won't touch the URL so it'll take it as is.