Is there any way to config fallback of async chunk on webpack 2?
This is what I want to have:
- Fail to load http://cdn.example.com/chunk-1.js -> load http://another-cdn.example.com/chunk-1.js
- Fail to load http://another-cdn.example.com/chunk-1.js -> load http://www.example.com/chunk-1.js
Like feature provided by Fallback JS
// Include `jQuery`.
"jQuery": {
// The URLs to load `jQuery`.
"urls": [
"//.....some-bad-cdn...../.....FAIL-ON-PURPOSE.....",
"//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min",
"//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min"
]
},
I have read the Code Splitting - Async documentation. There is no related options.
The closet way I got to the solution is to fire another jsonp request to a new url inside the require.ensure error callback, but I cannot get the chunk url from the error event.
======== Update on 12 June ========
Got some progress on this problem, but there is another road block. The public path can be changed dynamically, but I need to inject the code in webpack runtime code in manifest.js (generated by common chunk plugin).