-
Notifications
You must be signed in to change notification settings - Fork 65
Closed
Description
Issue
By default, Webpack generates sourcemap URLs relative to the output file.
dist/
index.html
scripts/
bundle.js
bundle.js.map
Sourcemap URL: 'bundle.js.map'
Relative to 'bundle.js', resolves to URL '/scripts/bundle.js.map'
OK!
Once we inline the output file, the sourcemaps will be loaded relative to the HTML file, which may not work:
dist/
index.html
scripts/
bundle.js
bundle.js.map
Sourcemap URL: 'bundle.js.map'
Relative to 'index.html', resolves to URL '/bundle.js.map'
NOT FOUND! :(
Even with source and maps in the top-level dist/ directory, sourcemaps won't work properly for URL paths when using HTML5 history routing:
dist/
index.html
bundle.js
bundle.js.map
Route 'some/route' serves 'index.html'
Sourcemap URL: 'bundle.js.map'
Relative to 'some/route', resolves to URL '/some/route/bundle.js.map'
NOT FOUND! :(
Solution
When inlining the JS, we should change the source map URL to be relative to the Webpack output.publicPath option.
dist/
index.html
scripts/
bundle.js
bundle.js.map
Sourcemap URL: '/scripts/bundle.js.map'
Absolute URL served from 'dist/' will correctly resolve to sourcemap file
FIXED! :)
Metadata
Metadata
Assignees
Labels
No labels