Mateusz Rybin Mateusz Rybin - 1 year ago 93
React JSX Question

Make all images file point to CDN using Webpack

In Ruby on Rails you can just adjust a single line of code to make all the assets use an external assets server. Inside

you just uncomment a line:

config.action_controller.asset_host = ''

So I would like to do the same on a react app. I have used s3-plugin-webpack to upload all the assets but I have having problem changing the url to point to the new images that have just been uploaded.

I work on a isomorphic React app so it render both on server and client side. So I don't looking to make the application run from the CDN.

Answer Source

Try configuring {output: {publicPath: ''}} for your production builds. The URLs in the compilation should then point to the assets on the CDN.

Alternatively, you can configure cdnizer with the plugin which should transform all the URLs in the HTML files in your output.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download