Christian Schlensker
Christian Schlensker

Reputation: 22508

How to make webpack use multiple urls for publicPath config

I know in webpack you can set the publicPath to a cdn URL like so:

// Example CDN
output: {
    path: "/home/proj/cdn/assets/[hash]",
    publicPath: "http://cdn.example.com/assets/[hash]/"
}

but how do you accomplish the trick of having multiple CDN aliases to improve load performance?

eg:

Upvotes: 5

Views: 1383

Answers (1)

I don't think webpack supports that yet. I had a quick look at the source and it seems to expect a static value. You probably should open an issue unless you can find a matching one.

As a temporary hack you could try something a little clever. Set publicPath to something that's easy to replace. Then, using another script, detect those and perform replacement according to your logic. That might be a good workaround for now.

Upvotes: 1

Related Questions