diff --git a/packages/uni-quickapp/lib/chain-webpack.js b/packages/uni-quickapp/lib/chain-webpack.js index 37c4cea507f8ec1b807d5c2796a5ac96ebc5d313..d6634407c2c66cf9e0927d3ae79897265b49574b 100644 --- a/packages/uni-quickapp/lib/chain-webpack.js +++ b/packages/uni-quickapp/lib/chain-webpack.js @@ -8,6 +8,7 @@ module.exports = config => { .tap(options => Object.assign(options, { compiler: require('@dcloudio/uni-template-compiler'), compilerOptions: { + quickapp: true, preserveWhitespace: false }, hotReload: false, diff --git a/packages/uni-quickapp/lib/compiler-module.js b/packages/uni-quickapp/lib/compiler-module.js new file mode 100644 index 0000000000000000000000000000000000000000..fde527550885d116574897b07a1d4661d47ac532 --- /dev/null +++ b/packages/uni-quickapp/lib/compiler-module.js @@ -0,0 +1,7 @@ +module.exports = { + preTransformNode(el) { + if (el.tag === 'view') { // view 是最常用组件,直接映射为div标签,保证性能 + el.tag = 'div' + } + } +} diff --git a/packages/uni-template-compiler/lib/index.js b/packages/uni-template-compiler/lib/index.js index ff13c3db73f05cee8ba2fff9694fd4dc86b3959d..925dc967e2a7b88ade009a0c36ef6096f9d02bd7 100644 --- a/packages/uni-template-compiler/lib/index.js +++ b/packages/uni-template-compiler/lib/index.js @@ -72,9 +72,12 @@ module.exports = { console.error(source) throw e } + } else if (options.quickapp) { + // 后续改版,应统一由具体包实现 + (options.modules || (options.modules = [])).push(require('@dcloudio/uni-quickapp/lib/compiler-module')) } - if (!options.mp) { // h5 + if (!options.mp) { // h5,quickapp return compileTemplate(source, options, compile) }