fix(webpack): prevent terser mangling html/vue reserved tags (#4821)

This commit is contained in:
Kevin Marrec 2019-01-20 22:19:53 +01:00 committed by Pooya Parsa
parent 6a5d0725d2
commit 6a68f4e981
3 changed files with 31 additions and 0 deletions

View File

@ -17,6 +17,8 @@ import PerfLoader from '../utils/perf-loader'
import StyleLoader from '../utils/style-loader'
import WarnFixPlugin from '../plugins/warnfix'
import { reservedVueTags } from '../utils/reserved-tags'
export default class WebpackBaseConfig {
constructor(builder, options) {
this.name = options.name
@ -156,6 +158,9 @@ export default class WebpackBaseConfig {
},
output: {
comments: /^\**!|@preserve|@license|@cc_on/
},
mangle: {
reserved: reservedVueTags
}
}
}, this.options.build.terser))

View File

@ -0,0 +1,3 @@
export { default as PerfLoader } from './perf-loader'
export { default as StyleLoader } from './style-loader'
export { reservedVueTags } from './reserved-tags'

View File

@ -0,0 +1,23 @@
export const reservedVueTags = [
// HTML tags
'html', 'body', 'base', 'head', 'link', 'meta', 'style', 'title', 'address',
'article', 'aside', 'footer', 'header', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'hgroup', 'nav', 'section', 'div', 'dd', 'dl', 'dt', 'figcaption', 'figure',
'picture', 'hr', 'img', 'li', 'main', 'ol', 'p', 'pre', 'ul', 'a', 'b', 'abbr',
'bdi', 'bdo', 'br', 'cite', 'code', 'data', 'dfn', 'em', 'i', 'kbd', 'mark',
'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'small', 'span', 'strong', 'sub',
'sup', 'time', 'u', 'var', 'wbr', 'area', 'audio', 'map', 'track', 'video',
'embed', 'object', 'param', 'source', 'canvas', 'script', 'noscript', 'del',
'ins', 'caption', 'col', 'colgroup', 'table', 'thead', 'tbody', 'td', 'th', 'tr',
'button', 'datalist', 'fieldset', 'form', 'input', 'label', 'legend', 'meter',
'optgroup', 'option', 'output', 'progress', 'select', 'textarea', 'details',
'dialog', 'menu', 'menuitem', 'summary', 'content', 'element', 'shadow', 'template',
'blockquote', 'iframe', 'tfoot',
// SVG tags
'svg', 'animate', 'circle', 'clippath', 'cursor', 'defs', 'desc', 'ellipse', 'filter',
'font-face', 'foreignObject', 'g', 'glyph', 'image', 'line', 'marker', 'mask',
'missing-glyph', 'path', 'pattern', 'polygon', 'polyline', 'rect', 'switch', 'symbol',
'text', 'textpath', 'tspan', 'use', 'view',
// Vue built-in tags
'slot', 'component'
]