diff --git a/.gitignore b/.gitignore index c8bd55941fae4bccca6a7c974d9a4a5869264784..83c062940cdde775767686824e44aa43259fe60e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ unpackage/ !packages/uni-app-plus/dist package-lock.json !packages/vue-cli-plugin-uni/packages/**/* +tests/package.json diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index 713d7058d55051987e1e5f23b4d18467e21c0def..5557d24d48703d93db72b630361b0db92be83b3a 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -58,7 +58,9 @@ if (process.env.UNI_CLOUD_SPACES) { const hasUniCloudSpace = spaces.length > 0 if (spaces.length === 1) { const space = spaces[0] - console.log(uniI18n.__('pluginUni.currentProjectDefaultSpaceId', { 0: space.id })) + console.log(uniI18n.__('pluginUni.currentProjectDefaultSpaceId', { + 0: space.id + })) } if ( @@ -66,13 +68,17 @@ if (process.env.UNI_CLOUD_SPACES) { isH5 && isProduction ) { - console.warn(uniI18n.__('pluginUni.unicloudReleaseH5', { 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' })) + console.warn(uniI18n.__('pluginUni.unicloudReleaseH5', { + 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' + })) } else if ( hasUniCloudSpace && isH5 && !isProduction ) { - console.warn(uniI18n.__('pluginUni.unicloudShowedRunByHBuilderX', { 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' })) + console.warn(uniI18n.__('pluginUni.unicloudShowedRunByHBuilderX', { + 0: 'https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5' + })) } process.env.UNI_CLOUD_PROVIDER = JSON.stringify(spaces.map(space => { @@ -122,6 +128,12 @@ if (process.env.NODE_ENV === 'production') { // 发行模式,不启用 cache delete process.env.UNI_USING_CACHE } +process.env.BROWSERSLIST_CONFIG = [ + path.resolve(process.env.UNI_INPUT_DIR, '.browserslistrc'), + path.resolve(process.env.UNI_CLI_CONTEXT, 'package.json'), + path.resolve(process.cwd(), 'package.json') +].find(file => fs.existsSync(file)) + const { normalizePath, isSupportSubPackages, @@ -295,7 +307,9 @@ if ( process.env.UNI_USING_STAT = true if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') { console.log() - console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { 0: 'https://ask.dcloud.net.cn/article/36303' })) + console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { + 0: 'https://ask.dcloud.net.cn/article/36303' + })) console.log() } } @@ -324,7 +338,10 @@ let hasNVue = false const compileModeUrl = 'https://ask.dcloud.net.cn/article/36074' if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { const compileMode = (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + ':' + (isNVueCompiler ? 'uni-app' : 'weex') - console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { 0: compileMode, 1: compileModeUrl })) + console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { + 0: compileMode, + 1: compileModeUrl + })) } else if (process.env.UNI_PLATFORM !== 'h5' && process.env.UNI_PLATFORM !== 'quickapp-native') { try { let info = '' @@ -332,7 +349,8 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { const pagesPkg = require('@dcloudio/webpack-uni-pages-loader/package.json') if (pagesPkg) { const v3Tips = `(v3)${uniI18n.__('see')}:https://ask.dcloud.net.cn/article/36599。` - info = uniI18n.__('compilerVersion') + ':' + pagesPkg['uni-app'].compilerVersion + (process.env.UNI_USING_V3 ? v3Tips : '') + info = uniI18n.__('compilerVersion') + ':' + pagesPkg['uni-app'].compilerVersion + (process.env.UNI_USING_V3 + ? v3Tips : '') } if (process.env.UNI_USING_V3) { console.log(info) @@ -346,7 +364,10 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { if (needWarning) { console.log(warningMsg) } - console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { 0: (isNVueCompiler ? 'uni-app' : 'weex'), 1: compileModeUrl })) + console.log(uniI18n.__('pluginUni.nvueCompileModeForDetail', { + 0: (isNVueCompiler ? 'uni-app' : 'weex'), + 1: compileModeUrl + })) } else { console.log(info) if (needWarning) { @@ -467,11 +488,13 @@ if ( } if (process.env.UNI_PLATFORM.startsWith('mp-')) { - console.log(uniI18n.__('pluginUni.mpBrowserKernelDifference', { 0: 'https://uniapp.dcloud.io/matter?id=mp' })) + console.log(uniI18n.__('pluginUni.mpBrowserKernelDifference', { + 0: 'https://uniapp.dcloud.io/matter?id=mp' + })) } runByHBuilderX && console.log(uniI18n.__('compiling')) module.exports = { manifestPlatformOptions: platformOptions -} +} diff --git a/packages/webpack-uni-pages-loader/lib/index-new.js b/packages/webpack-uni-pages-loader/lib/index-new.js index 049081ac64e29073ad867c7633779f3f655b611c..857e2140c78ce1ed8b205580b4cdbcffa54e7ea3 100644 --- a/packages/webpack-uni-pages-loader/lib/index-new.js +++ b/packages/webpack-uni-pages-loader/lib/index-new.js @@ -38,7 +38,7 @@ const { } = require('@dcloudio/uni-i18n') // 将开发者手动设置的 usingComponents 调整名称,方便与自动解析到的 usingComponents 做最后合并 -function renameUsingComponents(jsonObj) { +function renameUsingComponents (jsonObj) { if (jsonObj.usingComponents) { jsonObj.customUsingComponents = jsonObj.usingComponents delete jsonObj.usingComponents @@ -46,7 +46,7 @@ function renameUsingComponents(jsonObj) { return jsonObj } -module.exports = function(content, map) { +module.exports = function (content, map) { this.cacheable && this.cacheable() initTheme() @@ -136,13 +136,13 @@ module.exports = function(content, map) { if (!process.env.UNI_USING_V3) { parsePages( pagesJson, - function(page) { + function (page) { updatePageJson( page.path, renameUsingComponents(parseStyle(page.style)) ) }, - function(root, page) { + function (root, page) { updatePageJson( normalizePath(path.join(root, page.path)), renameUsingComponents(parseStyle(page.style, root))