@rspack/plugin-postcss
Advanced tools
Comparing version 0.0.0-1bce45e7c0-20221109113710 to 0.0.0-2d61de1089-20221122042420
# rspack-plugin-postcss | ||
## 0.0.0-1bce45e7c0-20221109113710 | ||
## 0.0.0-2d61de1089-20221122042420 | ||
### Patch Changes | ||
- e6d0926a29: unify version | ||
- Updated dependencies [e6d0926a29] | ||
- @rspack/binding@0.0.0-1bce45e7c0-20221109113710 | ||
- @rspack/binding@0.0.0-2d61de1089-20221122042420 | ||
## 0.0.10 | ||
### Patch Changes | ||
- @rspack/binding@0.0.10 | ||
## 0.0.9 | ||
### Patch Changes | ||
- Updated dependencies [69becfa5] | ||
- @rspack/binding@0.0.9 | ||
## 0.0.8 | ||
### Patch Changes | ||
- 589b99bb: bump to 0.0.8 | ||
- Updated dependencies [589b99bb] | ||
- @rspack/binding@0.0.8 | ||
## 0.0.6 | ||
### Patch Changes | ||
- e6d0926a: unify version | ||
- Updated dependencies [e6d0926a] | ||
- @rspack/binding@0.0.6 | ||
## 0.0.4 | ||
@@ -12,0 +39,0 @@ |
{ | ||
"name": "@rspack/plugin-postcss", | ||
"version": "0.0.0-1bce45e7c0-20221109113710", | ||
"version": "0.0.0-2d61de1089-20221122042420", | ||
"description": "", | ||
@@ -8,12 +8,7 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"@rspack/binding": "0.0.0-1bce45e7c0-20221109113710", | ||
"postcss-modules": "^5.0.0", | ||
"postcss-pxtorem": "^6.0.0" | ||
"postcss-pxtorem": "^6.0.0", | ||
"postcss": "^8.4.16", | ||
"@rspack/binding": "0.0.0-2d61de1089-20221122042420" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^7.0.0 || ^8.0.1" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.4.16" | ||
}, | ||
"author": "", | ||
@@ -20,0 +15,0 @@ "license": "ISC", |
@@ -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 @@ |
6024
0
164
+ Addedpostcss@^8.4.16
+ Added@rspack/binding@0.0.0-2d61de1089-20221122042420(transitive)
- Removed@rspack/binding@0.0.0-1bce45e7c0-20221109113710(transitive)