Skip to content

Commit

Permalink
fix(taro-cli): 修复小程序端非生产模式下不应用 csso 配置问题 close #3622 (#3623)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garfield550 authored and luckyadam committed Jul 2, 2019
1 parent dbc9b6b commit 40cba83
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/taro-cli/src/mini/compileStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,15 @@ export function compileDepStyles (outputFilePath: string, styleFiles: string[])
await Promise.all(resList.map(res => processStyleWithPostCSS(res)))
.then(cssList => {
let resContent = cssList.map(res => res).join('\n')
// 非生产模式下用户 csso 配置不存在则默认 csso 为禁用
let cssoPuginConfig = pluginsConfig.csso || { enable: false }
if (isProduction) {
const cssoPuginConfig = pluginsConfig.csso || { enable: true }
if (cssoPuginConfig.enable) {
const cssoConfig = cssoPuginConfig.config || {}
const cssoResult = callPluginSync('csso', resContent, outputFilePath, cssoConfig, appPath)
resContent = cssoResult.css
}
cssoPuginConfig = pluginsConfig.csso || { enable: true }
}
if (cssoPuginConfig.enable) {
const cssoConfig = cssoPuginConfig.config || {}
const cssoResult = callPluginSync('csso', resContent, outputFilePath, cssoConfig, appPath)
resContent = cssoResult.css
}
fs.ensureDirSync(path.dirname(outputFilePath))
fs.writeFileSync(outputFilePath, resContent)
Expand Down

0 comments on commit 40cba83

Please sign in to comment.