bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

Is there any way to prefix generated urls in order to turn them into absolute urls? #24

Closed throoze closed 8 years ago

throoze commented 8 years ago

Hi! im building this library, which, as specified in the README.md file, not only will be distributed via npm, but is also intended to be included in the html as a script tag.

<script type="text/javascript" src="http://driverwebchat1600.cloudapp.net/chattigo-webchat.js"></script>

The problem is that the library uses images and fonts as external resources, which are included, but the generated urls for including them are relative, which is the expected behavior. Let's say one of the generated urls is /fa2772327f55d8198301fdb8bcfc8158.woff. Is there an option that I can set somewhere that allow me to prefix this generated url with my current domain? in a way that the generated url results in something like: http://driverwebchat1600.cloudapp.net/fa2772327f55d8198301fdb8bcfc8158.woff, so it can be correctly requested?

Thanks for your help!

bholloway commented 8 years ago

The resolve-url-loader allows you to specify your assets in a relative fashion. Once webpack finds the asset it is up to webpack what to do with it. Typically you would use the webpack publicPath to add the CDN prefix.

If the problem is that you don't want resolve-url-loader to be operating on specific files then you need more specific filter for your loaders.

Any of that help?

throoze commented 8 years ago

Yes! thanks for your help! publicPath did the work.

bholloway commented 8 years ago

cool. glad to help.