提交 4abf0c6c 编写于 作者: fxy060608's avatar fxy060608

feat(cli): add sub platform

上级 5b09047a
...@@ -25,8 +25,8 @@ if (!pluginDir) { ...@@ -25,8 +25,8 @@ if (!pluginDir) {
process.exit(0) process.exit(0)
} }
if(pluginDir.indexOf('/') === -1){ if (pluginDir.indexOf('/') === -1) {
pluginDir = path.resolve(__dirname,'../packages/uni-'+pluginDir) pluginDir = path.resolve(__dirname, '../packages/uni-' + pluginDir)
} }
const pkg = require(path.join(pluginDir, 'package.json')) const pkg = require(path.join(pluginDir, 'package.json'))
......
...@@ -6,6 +6,7 @@ const Plugin = { ...@@ -6,6 +6,7 @@ const Plugin = {
options: {}, options: {},
// 初步校验相关配置是否正确 // 初步校验相关配置是否正确
validate: [], // (platformOptions, manifestJson) {}, validate: [], // (platformOptions, manifestJson) {},
configureEnv: [], // (){},
// 以 H5 为基准的平台特殊配置 // 以 H5 为基准的平台特殊配置
configureH5: [], // (h5Options) {}, configureH5: [], // (h5Options) {},
// 链式修改 webpack config // 链式修改 webpack config
...@@ -41,13 +42,14 @@ const pluginRE = /^(uni-|@[\w-]+(\.)?[\w-]+\/uni-)/ ...@@ -41,13 +42,14 @@ const pluginRE = /^(uni-|@[\w-]+(\.)?[\w-]+\/uni-)/
const officialPlugins = [ const officialPlugins = [
'@dcloudio/uni-app-plus', '@dcloudio/uni-app-plus',
'@dcloudio/uni-h5', '@dcloudio/uni-h5',
'@dcloudio/uni-mp-360',
'@dcloudio/uni-mp-alipay', '@dcloudio/uni-mp-alipay',
'@dcloudio/uni-mp-baidu', '@dcloudio/uni-mp-baidu',
'@dcloudio/uni-mp-qq', '@dcloudio/uni-mp-qq',
'@dcloudio/uni-mp-toutiao', '@dcloudio/uni-mp-toutiao',
'@dcloudio/uni-mp-welink', '@dcloudio/uni-mp-welink',
'@dcloudio/uni-mp-weixin' '@dcloudio/uni-mp-weixin'
] ]
function resolvePlugins () { function resolvePlugins () {
......
...@@ -396,6 +396,10 @@ if (process.UNI_AUTO_SCAN_COMPONENTS) { ...@@ -396,6 +396,10 @@ if (process.UNI_AUTO_SCAN_COMPONENTS) {
initAutoImportScanComponents() initAutoImportScanComponents()
} }
global.uniPlugin.configureEnv.forEach(configureEnv => {
configureEnv()
})
runByHBuilderX && console.log(`正在编译中...`) runByHBuilderX && console.log(`正在编译中...`)
module.exports = { module.exports = {
......
...@@ -66,6 +66,10 @@ const getPageComponents = function (inputDir, pagesJson) { ...@@ -66,6 +66,10 @@ const getPageComponents = function (inputDir, pagesJson) {
globalStyle['h5'] || {} globalStyle['h5'] || {}
) )
if (process.env.UNI_SUB_PLATFORM) {
Object.assign(globalStyle, globalStyle[process.env.UNI_SUB_PLATFORM] || {})
}
process.UNI_H5_PAGES_JSON = { process.UNI_H5_PAGES_JSON = {
pages: {}, pages: {},
globalStyle globalStyle
...@@ -90,6 +94,11 @@ const getPageComponents = function (inputDir, pagesJson) { ...@@ -90,6 +94,11 @@ const getPageComponents = function (inputDir, pagesJson) {
// 解析 titleNView,pullToRefresh // 解析 titleNView,pullToRefresh
const h5Options = Object.assign({}, props['app-plus'] || {}, props['h5'] || {}) const h5Options = Object.assign({}, props['app-plus'] || {}, props['h5'] || {})
if (process.env.UNI_SUB_PLATFORM) {
Object.assign(h5Options, props[process.env.UNI_SUB_PLATFORM] || {})
Object.assign(props, props[process.env.UNI_SUB_PLATFORM] || {})
}
removePlatformStyle(h5Options) removePlatformStyle(h5Options)
if (h5Options.hasOwnProperty('titleNView')) { if (h5Options.hasOwnProperty('titleNView')) {
...@@ -121,7 +130,11 @@ const getPageComponents = function (inputDir, pagesJson) { ...@@ -121,7 +130,11 @@ const getPageComponents = function (inputDir, pagesJson) {
// 删除 app-plus 平台配置 // 删除 app-plus 平台配置
delete props['app-plus'] delete props['app-plus']
delete props['h5'] delete props['h5']
if (process.env.UNI_SUB_PLATFORM) {
delete props[process.env.UNI_SUB_PLATFORM]
}
process.UNI_H5_PAGES_JSON.pages[page.path] = props process.UNI_H5_PAGES_JSON.pages[page.path] = props
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册