diff --git a/packages/next/pages/_document.js b/packages/next/pages/_document.js index 8638e76f86afaeeaee75f1e908041213a6837d55..336f690b3f8d557b9dc68c22b2325a615d7b3940 100644 --- a/packages/next/pages/_document.js +++ b/packages/next/pages/_document.js @@ -197,7 +197,9 @@ export class Head extends Component { dangerouslySetInnerHTML={{ __html: styles .map(style => style.props.dangerouslySetInnerHTML.__html) - .join(''), + .join('') + .replace(/\/\*# sourceMappingURL=.*\*\//g, '') + .replace(/\/\*@ sourceURL=.*?\*\//g, '') }} /> )} diff --git a/test/integration/amphtml/test/index.test.js b/test/integration/amphtml/test/index.test.js index 57b820271683b45cbf08e684b25ff945bb480d0c..f98b22cdb220a47445ca1012244ac42f506cf386 100644 --- a/test/integration/amphtml/test/index.test.js +++ b/test/integration/amphtml/test/index.test.js @@ -158,6 +158,15 @@ describe('AMP Usage', () => { /div.jsx-\d+{color:red;}span.jsx-\d+{color:blue;}body{background-color:green;}/ ) }) + + it('should remove sourceMaps from styles', async () => { + const html = await renderViaHTTP(appPort, '/styled?amp=1') + const $ = cheerio.load(html) + const styles = $('style[amp-custom]').first().text() + + expect(styles).not.toMatch(/\/\*@ sourceURL=.*?\*\//) + expect(styles).not.toMatch(/\/\*# sourceMappingURL=.*\*\//) + }) }) describe('editing a page', () => {