提交 69b53bfc 编写于 作者: J JJ Kasper 提交者: 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
上级 d5f736d6
......@@ -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, '')
}}
/>
)}
......
......@@ -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', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册