Skip to content

Commit

Permalink
fix(webpack-runner): 修复h5样式丢失的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Nov 22, 2018
1 parent 0f7678f commit 64d8cc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 4 additions & 6 deletions packages/taro-webpack-runner/src/config/postcss.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const getPostcssPlugins = function ({
deviceRatio,
postcssOption = {} as PostcssOption
}) {
const autoprefixerOption = Object.assign({}, defaultAutoprefixerOption, postcssOption.autoprefixer)

if (designWidth) {
defaultPxtransformOption.config.designWidth = designWidth
Expand All @@ -59,21 +58,20 @@ export const getPostcssPlugins = function ({
defaultPxtransformOption.config.deviceRatio = deviceRatio
}

const autoprefixerOption = Object.assign({}, defaultAutoprefixerOption, postcssOption.autoprefixer)
const pxtransformOption = Object.assign({}, defaultPxtransformOption, postcssOption.pxtransform)
const cssModulesOption = Object.assign({}, defaultCssModulesOption, postcssOption.cssModules)

if (autoprefixerOption.enable) {
plugins.push(autoprefixer(autoprefixerOption as autoprefixer.Options))
plugins.push(autoprefixer(autoprefixerOption.config))
}

if (pxtransformOption.enable) {
defaultPxtransformOption.platform = defaultPxtransformOption.config.platform
plugins.push(pxtransform(defaultPxtransformOption))
plugins.push(pxtransform(pxtransformOption.config))
}

if (cssModulesOption.enable) {
const customCssModulesOption = postcssOption.cssModules ? postcssOption.cssModules.config : {}
plugins.push(modules(customCssModulesOption))
plugins.push(modules(cssModulesOption.config))
}

plugins.push(constparse(defaultConstparseOption))
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-webpack-runner/src/util/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as webpack from 'webpack'

import { appPath } from '.'
import { getPostcssPlugins } from '../config/postcss.conf'
import { Option } from './types'
import { Option, PostcssOption } from './types'


const defaultUglifyJsOption = {
Expand Down Expand Up @@ -137,7 +137,7 @@ const getModule = ({
module,
plugins
}) => {
const postcssOption = module.postcss || {}
const postcssOption: PostcssOption = module.postcss || {}

const styleLoader = getStyleLoader([{ sourceMap: enableSourceMap }, styleLoaderOption])

Expand All @@ -148,7 +148,8 @@ const getModule = ({
const cssOptions = [
{
importLoaders: 1,
sourceMap: enableSourceMap
sourceMap: enableSourceMap,
modules: postcssOption.cssModules && postcssOption.cssModules.enable
},
cssLoaderOption
]
Expand Down

0 comments on commit 64d8cc4

Please sign in to comment.