0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Removed assets/ from sources in admin sourcemaps (#18852)

no issue

- Follow up to
85fca5891f
- With the `sourceRoot` key added in the commit above, the sourcemaps
were still failing validation
(https://sourcemaps.io/report/1698954693695_https%3A%2F%2Fassets.ghostfoundation.org%2Fadmin%2F1603%2Fassets%2Fchunk.143.ab029856ba6d72733dfa.js)
- With the `sourceRoot` key, the maps were pointing to
'<CDN_URL>/assets/../assets/...' which is invalid
- This change simply strips the leading `assets/` from any sources in
the sourcemaps
This commit is contained in:
Chris Raible 2023-11-02 13:12:45 -07:00 committed by GitHub
parent cce3d12f45
commit 8a0a9c07fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,11 +68,12 @@ module.exports = {
ignore: ['icons']
});
// loop over any sourcemaps and add a "sourceRoot" key to each one before copying
// loop over any sourcemaps and remove `assets/` key from each one
assets.filter((file) => file.endsWith('.map')).forEach((file) => {
const mapFilePath = `${results.directory}/assets/${file}`;
const mapFile = JSON.parse(fs.readFileSync(mapFilePath, 'utf8'));
mapFile.sourceRoot = '../';
// loop over the sources and remove `assets/` from each one
mapFile.sources = mapFile.sources.map((source) => source.replace('assets/', ''));
fs.writeFileSync(mapFilePath, JSON.stringify(mapFile));
});