From abc0b71d1a7089087e19fca569aa0d9c20094e40 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 30 Jul 2019 15:01:36 +0800 Subject: [PATCH] update babel useBuiltIns --- template/common/babel.config.js | 54 +++++++++++++++---------------- template/common/postcss.config.js | 1 - 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/template/common/babel.config.js b/template/common/babel.config.js index d1dbfa8..a46c091 100644 --- a/template/common/babel.config.js +++ b/template/common/babel.config.js @@ -1,28 +1,28 @@ -const plugins = [] - -if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8) { - const path = require('path') - - const isWin = /^win/.test(process.platform) - - const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) - - const input = normalizePath(process.env.UNI_INPUT_DIR) - try { - plugins.push([ - require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'), - { - file (file) { - file = normalizePath(file) - if (file.indexOf(input) === 0) { - return path.relative(input, file) - } - return false - } - } - ]) - } catch (e) {} -} +const plugins = [] + +if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8) { + const path = require('path') + + const isWin = /^win/.test(process.platform) + + const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) + + const input = normalizePath(process.env.UNI_INPUT_DIR) + try { + plugins.push([ + require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'), + { + file (file) { + file = normalizePath(file) + if (file.indexOf(input) === 0) { + return path.relative(input, file) + } + return false + } + } + ]) + } catch (e) {} +} process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui'] process.UNI_LIBRARIES.forEach(libraryName => { @@ -40,9 +40,9 @@ module.exports = { presets: [ [ '@vue/app', - { + { modules: 'commonjs', - useBuiltIns: 'entry' + useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry' } ] ], diff --git a/template/common/postcss.config.js b/template/common/postcss.config.js index 4006fff..53b23e3 100644 --- a/template/common/postcss.config.js +++ b/template/common/postcss.config.js @@ -1,4 +1,3 @@ -const pkg = require('./package.json') module.exports = { parser: require('postcss-comment'), plugins: [