Skip to content

Commit

Permalink
fix postCssPlugins issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielAmenou-R2net committed Dec 5, 2022
1 parent ccaff8e commit 5f69aea
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/postCssTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ const postCssLoader = async ({code, fiePath, options}) => {
const isGlobalStyle = /\.global.(css|scss|sass|less|stylus)$/.test(fiePath)
const isInNodeModules = /[\\/]node_modules[\\/]/.test(fiePath)

postCssPlugins.unshift(
const postCssPluginsWithCssModules = [
postcssModules({
generateScopedName: isGlobalStyle || isInNodeModules ? "[local]" : classNamePrefix + scopedName,
generateScopedName: isInNodeModules || isGlobalStyle ? "[local]" : classNamePrefix + scopedName,
getJSON: (cssFileName, json) => (modulesExported[cssFileName] = json),
})
)
}),
...postCssPlugins,
]

const postcssOptions = {
from: fiePath,
to: fiePath,
map: false,
}

const result = await postcss(postCssPlugins).process(code, postcssOptions)
const result = await postcss(postCssPluginsWithCssModules).process(code, postcssOptions)

// collect dependencies
const dependencies = []
Expand Down

0 comments on commit 5f69aea

Please sign in to comment.