Skip to content

Instantly share code, notes, and snippets.

@tkdn
Created November 30, 2019 21:56
Show Gist options
  • Save tkdn/c5a7fbe2cf3fdd6515bf439c5bb7fb44 to your computer and use it in GitHub Desktop.
Save tkdn/c5a7fbe2cf3fdd6515bf439c5bb7fb44 to your computer and use it in GitHub Desktop.
20191201 Next.js アドカレ用
module.exports = class RewriteSourceMapUrlPlugin {
constructor({isServer}) {
this.isServer = isServer;
}
apply(compiler) {
compiler.plugin("emit", (compilation, callback) => {
const { assets } = compilation;
// クライアントのみ sourceMappingURL を書き換える
if (!this.isServer) {
for (const [filename, content] of Object.entries(assets)) {
if (/\.js$/.test(filename)) {
content.children[1] = "";
}
}
}
callback();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment