提交 535a3610 编写于 作者: fxy060608's avatar fxy060608

feat(cli): add isUnaryTag #625

上级 caeb0673
......@@ -2,6 +2,10 @@ const {
tags
} = require('@dcloudio/uni-cli-shared')
const {
isUnaryTag
} = require('../util')
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/
function processEvent (expr, filterModules) {
......@@ -41,6 +45,7 @@ function addTag (tag) {
}
module.exports = {
isUnaryTag,
preserveWhitespace: false,
modules: [require('../format-text'), {
preTransformNode (el, {
......
......@@ -13,6 +13,10 @@ const {
getPlatformCssnano
} = require('@dcloudio/uni-cli-shared')
const {
isUnaryTag
} = require('./util')
function createUniMPPlugin () {
if (process.env.UNI_USING_COMPONENTS) {
const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new')
......@@ -154,6 +158,7 @@ module.exports = {
.tap(options => Object.assign(options, {
compiler: getPlatformCompiler(),
compilerOptions: process.env.UNI_USING_COMPONENTS ? {
isUnaryTag,
preserveWhitespace: false
} : require('./mp-compiler-options'),
cacheDirectory: false,
......
function makeMap (str, expectsLowerCase) {
const map = Object.create(null)
const list = str.split(',')
for (let i = 0; i < list.length; i++) {
map[list[i]] = true
}
return expectsLowerCase
? val => map[val.toLowerCase()]
: val => map[val]
}
module.exports = {
isUnaryTag: makeMap(
'image,area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
'link,meta,param,source,track,wbr'
)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册