@rspack/plugin-postcss
Advanced tools
Comparing version 0.0.9 to 0.0.10
# rspack-plugin-postcss | ||
## 0.0.10 | ||
### Patch Changes | ||
- @rspack/binding@0.0.10 | ||
## 0.0.9 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@rspack/plugin-postcss", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "", | ||
@@ -8,3 +8,3 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"@rspack/binding": "0.0.9", | ||
"@rspack/binding": "0.0.10", | ||
"postcss-modules": "^5.0.0", | ||
@@ -11,0 +11,0 @@ "postcss-pxtorem": "^6.0.0" |
@@ -9,2 +9,4 @@ const { Processor } = require("postcss"); | ||
const IS_MODULES = /\.module(s)?\.\w+$/i; | ||
module.exports = async function loader(loaderContext) { | ||
@@ -14,3 +16,3 @@ // TODO: customize options, until js binding support this functionality | ||
let options = loaderContext.getOptions() ?? {}; | ||
let enableModules = options.modules; | ||
let modulesOptions = options.modules; | ||
let pxToRem = options.pxToRem; | ||
@@ -46,12 +48,29 @@ let useSourceMap = | ||
if (enableModules) { | ||
plugins.push( | ||
cssModules({ | ||
getJSON(_, json) { | ||
if (json) { | ||
meta = json; | ||
if (modulesOptions) { | ||
let auto = | ||
typeof modulesOptions === "boolean" | ||
? true | ||
: modulesOptions.auto ?? true; | ||
let isModules; | ||
if (typeof auto === "boolean") { | ||
isModules = auto && IS_MODULES.test(loaderContext.resourcePath); | ||
} else if (auto instanceof RegExp) { | ||
isModules = auto.test(loaderContext.resourcePath); | ||
} else if (typeof auto === "function") { | ||
isModules = auto(loaderContext.resourcePath); | ||
} | ||
delete modulesOptions.auto; | ||
if (isModules) { | ||
plugins.push( | ||
cssModules({ | ||
...modulesOptions, | ||
getJSON(_, json) { | ||
if (json) { | ||
meta = json; | ||
} | ||
} | ||
} | ||
}) | ||
); | ||
}) | ||
); | ||
} | ||
} | ||
@@ -58,0 +77,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5958
164
+ Added@rspack/binding@0.0.10(transitive)
- Removed@rspack/binding@0.0.9(transitive)
Updated@rspack/binding@0.0.10