mirror of
https://gitee.com/vuejs/vue.git
synced 2024-11-30 11:07:51 +08:00
feat(ssr): auto-remove initial state script if prod (#6763)
close #6761
This commit is contained in:
parent
dff85b230a
commit
2d32b5d1b6
@ -191,10 +191,13 @@ export default class TemplateRenderer {
|
||||
contextKey = 'state',
|
||||
windowKey = '__INITIAL_STATE__'
|
||||
} = options || {}
|
||||
const autoRemove = process.env.NODE_ENV === 'production'
|
||||
? '(function(){var s;(s=document.currentScript||document.scripts[document.scripts.length-1]).parentNode.removeChild(s);}());'
|
||||
: ''
|
||||
return context[contextKey]
|
||||
? `<script>window.${windowKey}=${
|
||||
serialize(context[contextKey], { isJSON: true })
|
||||
}</script>`
|
||||
}${autoRemove}</script>`
|
||||
: ''
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user