diff --git a/generator.js b/generator.js index 29f47b3..43f318b 100644 --- a/generator.js +++ b/generator.js @@ -35,7 +35,7 @@ module.exports = (api, options, rootOptions) => { api.extendPackage(pkg => { return { dependencies: { - 'regenerator-runtime':'^0.12.1'//锁定版本,避免高版本在小程序中出错 + 'regenerator-runtime': '^0.12.1'// 锁定版本,避免高版本在小程序中出错 } } }) diff --git a/template/common/babel.config.js b/template/common/babel.config.js index 81549ce..1355790 100644 --- a/template/common/babel.config.js +++ b/template/common/babel.config.js @@ -1,4 +1,29 @@ -const plugins = [] +const plugins = [] + +if (process.env.UNI_PLATFORM === 'app-plus') { + 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 => { plugins.push([