@dcloudio/uni-cli-shared
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -40,3 +40,5 @@ const tags = require('./tags') | ||
jsPreprocessOptions, | ||
htmlPreprocessOptions | ||
htmlPreprocessOptions, | ||
nvueJsPreprocessOptions, | ||
nvueHtmlPreprocessOptions | ||
} = require('./platform') | ||
@@ -70,3 +72,5 @@ | ||
jsPreprocessOptions, | ||
htmlPreprocessOptions | ||
htmlPreprocessOptions, | ||
nvueJsPreprocessOptions, | ||
nvueHtmlPreprocessOptions | ||
} |
const fs = require('fs') | ||
const path = require('path') | ||
const EXTS = { | ||
const PLATFORMS = { | ||
'h5': { | ||
exts: false, | ||
vue: '@dcloudio/vue-cli-plugin-uni/packages/h5-vue', | ||
compiler: false, | ||
megalo: false, | ||
cssVars: { | ||
'--status-bar-height': '0px' | ||
} | ||
}, | ||
'app-plus': { | ||
style: '.wxss', | ||
template: '.wxml' | ||
exts: { | ||
style: '.wxss', | ||
template: '.wxml' | ||
}, | ||
vue: '@dcloudio/vue-cli-plugin-uni/packages/mpvue', | ||
compiler: '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler', | ||
megalo: false, | ||
cssVars: { | ||
'--window-top': '0px', | ||
'--window-bottom': '0px' | ||
} | ||
}, | ||
'mp-weixin': { | ||
style: '.wxss', | ||
template: '.wxml' | ||
exts: { | ||
style: '.wxss', | ||
template: '.wxml' | ||
}, | ||
vue: '@dcloudio/vue-cli-plugin-uni/packages/mpvue', | ||
compiler: '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler', | ||
megalo: false, | ||
cssVars: { | ||
'--status-bar-height': '25px', | ||
'--window-top': '0px', | ||
'--window-bottom': '0px' | ||
} | ||
}, | ||
'mp-baidu': { | ||
style: '.css', | ||
template: '.swan' | ||
exts: { | ||
style: '.css', | ||
template: '.swan' | ||
}, | ||
vue: '@dcloudio/vue-cli-plugin-uni/packages/megalo', | ||
compiler: '@megalo/template-compiler', | ||
megalo: 'swan', | ||
cssVars: { | ||
'--status-bar-height': '25px', | ||
'--window-top': '0px', | ||
'--window-bottom': '0px' | ||
} | ||
}, | ||
'mp-alipay': { | ||
style: '.acss', | ||
template: '.axml' | ||
exts: { | ||
style: '.acss', | ||
template: '.axml' | ||
}, | ||
vue: '@dcloudio/vue-cli-plugin-uni/packages/megalo', | ||
compiler: '@megalo/template-compiler', | ||
megalo: 'alipay', | ||
cssVars: { | ||
'--status-bar-height': '25px', | ||
'--window-top': '0px', | ||
'--window-bottom': '0px' | ||
} | ||
}, | ||
'mp-toutiao': { | ||
} | ||
} | ||
const TARGETS = { | ||
'app-plus': 'wechat', | ||
'mp-weixin': 'wechat', | ||
'mp-baidu': 'swan', | ||
'mp-alipay': 'alipay' | ||
} | ||
const VUE_ALIAS = { | ||
'h5': '@dcloudio/vue-cli-plugin-uni/packages/h5-vue', | ||
'app-plus': '@dcloudio/vue-cli-plugin-uni/packages/mpvue', | ||
'mp-weixin': '@dcloudio/vue-cli-plugin-uni/packages/mpvue', | ||
'mp-baidu': '@dcloudio/vue-cli-plugin-uni/packages/megalo', | ||
'mp-alipay': '@dcloudio/vue-cli-plugin-uni/packages/megalo' | ||
} | ||
const isInHBuilderX = fs.existsSync(path.resolve(__dirname, '../../vue-cli-plugin-hbuilderx')) | ||
const COMPILERS = { | ||
'app-plus': '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler', | ||
'mp-weixin': '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler', | ||
'mp-baidu': '@megalo/template-compiler', | ||
'mp-alipay': '@megalo/template-compiler' | ||
} | ||
const platform = PLATFORMS[process.env.UNI_PLATFORM] | ||
const MP_CSS_VARS = { | ||
'--status-bar-height': '25px', | ||
'--window-top': '0px', | ||
'--window-bottom': '0px' | ||
} | ||
const APP_PLUS_CSS_VARS = { | ||
'--window-top': '0px', | ||
'--window-bottom': '0px' | ||
} | ||
const preprocessContext = {} | ||
const H5_CSS_VARS = { | ||
'--status-bar-height': '0px' | ||
} | ||
Object.keys(PLATFORMS).forEach(platform => { | ||
preprocessContext[platform.toUpperCase()] = false | ||
}) | ||
const CSS_VARS = { | ||
'h5': H5_CSS_VARS, | ||
'app-plus': APP_PLUS_CSS_VARS, | ||
'mp-weixin': MP_CSS_VARS, | ||
'mp-baidu': MP_CSS_VARS, | ||
'mp-alipay': MP_CSS_VARS | ||
} | ||
preprocessContext[process.env.UNI_PLATFORM.toUpperCase()] = true | ||
const preprocessContext = { | ||
[process.env.UNI_PLATFORM.toUpperCase()]: true | ||
} | ||
if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) { | ||
@@ -78,4 +94,13 @@ preprocessContext['MP'] = true | ||
const isInHBuilderX = fs.existsSync(path.resolve(__dirname, '../../vue-cli-plugin-hbuilderx')) | ||
Object.keys(preprocessContext).forEach(platform => { | ||
if (platform.indexOf('-') !== -1) { | ||
preprocessContext[platform.replace(/-/g, '_')] = preprocessContext[platform] | ||
} | ||
}) | ||
const nvuePreprocessContext = Object.assign({}, preprocessContext, { | ||
'APP-PLUS-NVUE': true, | ||
'APP_PLUS_NVUE': true | ||
}) | ||
module.exports = { | ||
@@ -91,17 +116,25 @@ isInHBuilderX, | ||
}, | ||
nvueJsPreprocessOptions: { | ||
type: 'js', | ||
context: nvuePreprocessContext | ||
}, | ||
nvueHtmlPreprocessOptions: { | ||
type: 'html', | ||
context: nvuePreprocessContext | ||
}, | ||
getPlatformExts () { | ||
return EXTS[process.env.UNI_PLATFORM] | ||
return platform.exts | ||
}, | ||
getPlatformTarget () { | ||
return TARGETS[process.env.UNI_PLATFORM] | ||
return platform.megalo | ||
}, | ||
getPlatformVue () { | ||
return VUE_ALIAS[process.env.UNI_PLATFORM] | ||
return platform.vue | ||
}, | ||
getPlatformCompiler () { | ||
return require(COMPILERS[process.env.UNI_PLATFORM]) | ||
return require(platform.compiler) | ||
}, | ||
getPlatformCssVars () { | ||
return CSS_VARS[process.env.UNI_PLATFORM] | ||
return platform.cssVars | ||
} | ||
} |
{ | ||
"name": "@dcloudio/uni-cli-shared", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "uni-cli-shared", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
27288
556
19