Created
November 30, 2019 21:56
-
-
Save tkdn/c5a7fbe2cf3fdd6515bf439c5bb7fb44 to your computer and use it in GitHub Desktop.
20191201 Next.js アドカレ用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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