mirror of
https://github.com/c8r/x0.git
synced 2024-09-11 13:45:52 +03:00
Add full html minification
Before, the joining of the different document parts resulted in added whitespace. We now use an array and join to ensure whitespace is squeezed when combining.
This commit is contained in:
parent
6aea528370
commit
f1507c638c
@ -21,13 +21,16 @@ const createHTML = ({
|
||||
css = '',
|
||||
initialProps,
|
||||
scripts = []
|
||||
}) => (`<!DOCTYPE html>
|
||||
<meta charset='utf-8'>
|
||||
${css}
|
||||
${body}
|
||||
${initialProps ? `<script id='__initial-props__' type='application/json'>${JSON.stringify(initialProps)}</script>` : ''}
|
||||
${scripts.map(src => `<script src='${src}'></script>`)}
|
||||
`)
|
||||
}) => ([
|
||||
'<!DOCTYPE html><meta charset="utf-8">',
|
||||
css,
|
||||
body,
|
||||
propsScript(initialProps),
|
||||
scripts.map(src => `<script src="${src}"></script>`).join('')
|
||||
].join(''))
|
||||
|
||||
const propsScript = initialProps =>
|
||||
initialProps ? `<script id="__initial-props__" type="application/json">${JSON.stringify(initialProps)}</script>` : ''
|
||||
|
||||
const render = (Component, props, isStatic) =>
|
||||
(isStatic ? renderToStaticMarkup : renderToString)(
|
||||
|
@ -16,34 +16,16 @@ Generated by [AVA](https://ava.li).
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<!DOCTYPE html>␊
|
||||
<meta charset='utf-8'>␊
|
||||
␊
|
||||
<h1>Hello</h1>␊
|
||||
␊
|
||||
␊
|
||||
`
|
||||
'<!DOCTYPE html><meta charset="utf-8"><h1>Hello</h1>'
|
||||
|
||||
## static uses getInitialProps method
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<!DOCTYPE html>␊
|
||||
<meta charset='utf-8'>␊
|
||||
␊
|
||||
<h1>Hello</h1>␊
|
||||
␊
|
||||
␊
|
||||
`
|
||||
'<!DOCTYPE html><meta charset="utf-8"><h1>Hello</h1>'
|
||||
|
||||
## static writes
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
`<!DOCTYPE html>␊
|
||||
<meta charset='utf-8'>␊
|
||||
␊
|
||||
<h1 data-reactroot="">Hello</h1>␊
|
||||
<script id='__initial-props__' type='application/json'>{"outDir":"test/output"}</script>␊
|
||||
<script src='/bundle.js'></script>␊
|
||||
`
|
||||
'<!DOCTYPE html><meta charset="utf-8"><h1 data-reactroot="">Hello</h1><script id="__initial-props__" type="application/json">{"outDir":"test/output"}</script><script src="/bundle.js"></script>'
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user