Commit 69b53bfc authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Remove sourceMaps from amp styles to not go over limit (#6674)

* Remove sourceMaps from amp styles to not go over limit

* Add test to make sure style sourceMaps
are removed in amp
parent d5f736d6
...@@ -197,7 +197,9 @@ export class Head extends Component { ...@@ -197,7 +197,9 @@ export class Head extends Component {
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: styles __html: styles
.map(style => style.props.dangerouslySetInnerHTML.__html) .map(style => style.props.dangerouslySetInnerHTML.__html)
.join(''), .join('')
.replace(/\/\*# sourceMappingURL=.*\*\//g, '')
.replace(/\/\*@ sourceURL=.*?\*\//g, '')
}} }}
/> />
)} )}
......
...@@ -158,6 +158,15 @@ describe('AMP Usage', () => { ...@@ -158,6 +158,15 @@ describe('AMP Usage', () => {
/div.jsx-\d+{color:red;}span.jsx-\d+{color:blue;}body{background-color:green;}/ /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', () => { describe('editing a page', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment