Skip to content

Commit

Permalink
feat(RN): RN 端支持 deviceRatio 自定义
Browse files Browse the repository at this point in the history
  • Loading branch information
Pines-Cheng committed Oct 10, 2018
1 parent 5c0a59c commit 654c423
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/taro-cli/src/rn/styleProcess.js
Expand Up @@ -8,6 +8,8 @@ const {StyleSheetValidation} = require('./StyleSheet/index')
const Util = require('../util')
const npmProcess = require('../util/npm')

const DEVICE_RATIO = 'deviceRatio'

/**
* @description 读取 css/scss/less 文件,预处理后,返回 css string
* @param {string}filePath
Expand Down Expand Up @@ -50,9 +52,15 @@ function loadStyle ({filePath, pluginsConfig}) {
* @returns {Function | any}
*/
function postCSS ({css, filePath, projectConfig}) {
let pxTransformConfig = {
designWidth: projectConfig.designWidth || 750
}
if (projectConfig.hasOwnProperty(DEVICE_RATIO)) {
pxTransformConfig[DEVICE_RATIO] = projectConfig.deviceRatio
}
return postcss(pxtransform({
platform: 'rn',
designWidth: projectConfig.designWidth || 750
...pxTransformConfig
}))
.process(css, {from: filePath})
.then((result) => {
Expand Down

0 comments on commit 654c423

Please sign in to comment.