-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcemaps are not emitted when excluded with deleteOriginalAssets
option
#215
Comments
Expected, remove original source means remove source maps too |
Thanks @evilebottnawi . Anyway we could achieve this? I believe this is a general expectation. If this can't be fixed. Compression has to be done outside webpack I guess. |
I was just thinking |
No new options, we can improve this, |
Sounds good. I can give it a try. Can you put out a help wanted label. Incase you are busy. Someone can take this? |
Yes, but nobody will take 😄 because it OSS |
I think I was wrong here, look at https:/webpack-contrib/compression-webpack-plugin/blob/master/src/index.js#L303, it is easy: if (this.options.deleteOriginalAssets) {
if (this.options.deleteOriginalAssets === 'keep-source-map) {
CompressionPlugin.updateAsset(
compilation,
name,
inputSource,
// Here we have link on source map file, we should just remove it from object and webpack keep source maps
{}
);
}
CompressionPlugin.deleteAsset(compilation, name);
} |
You can try, it should be really easy |
Sure. Thanks for the tip. |
const newAssetInfo = {
...info,
related: { ...info.related, sourceMap: null },
};
CompressionPlugin.updateAsset(compilation, name, inputSource, newAssetInfo); @evilebottnawi . removing the |
Let's use |
Actually thats what I did first. if (this.options.deleteOriginalAssets) {
if (this.options.deleteOriginalAssets === "keep-source-map") {
const { sourceMap, ...related } = info.related || {}; // <--- Removing the source map property.
const newOriginalInfo = {
...info,
related,
};
CompressionPlugin.updateAsset(
compilation,
name,
inputSource,
newOriginalInfo
);
console.log(newOriginalInfo);
}
const currentAsset = CompressionPlugin.getAsset(compilation, name);
console.log(currentAsset.info); // <--- Still having source-map property in related info
CompressionPlugin.deleteAsset(compilation, name);
} else {
// existing logic
} only setting a new value to it works. else the property is added back again. |
Do it work? |
Setting it to null works. but I am just little not sure if it, whether it will create any unintended sideeffects? |
No side effect, here simple logic, when something removed webpack automatically remove all related, so if you want keep something just remove it from |
Expected Behavior
Sourcemap should be emitted with
deleteOriginalAssets
when excluded from compression.Actual Behavior
When
deleteOriginalAssets
is enabled and map files are excluded from the compression. It is expected thatjs
files are compressed with the same filename and map files are emitted as it is. but the map files are not emitted.Code
How Do We Reproduce?
Run webapck with the given config. the dist folder should have a compressed
main.js
and uncompressedmain.js.map
, but the map file is not emitted.The text was updated successfully, but these errors were encountered: