@rspack/plugin-postcss
Advanced tools
Comparing version 0.0.0-28c9a9ca7c-20221122072855 to 0.0.0-2b6f22786b-20221128111122
# rspack-plugin-postcss | ||
## 0.0.0-28c9a9ca7c-20221122072855 | ||
## 0.0.0-2b6f22786b-20221128111122 | ||
### Patch Changes | ||
- @rspack/binding@0.0.0-28c9a9ca7c-20221122072855 | ||
- @rspack/binding@0.0.0-2b6f22786b-20221128111122 | ||
@@ -9,0 +9,0 @@ ## 0.0.10 |
{ | ||
"name": "@rspack/plugin-postcss", | ||
"version": "0.0.0-28c9a9ca7c-20221122072855", | ||
"version": "0.0.0-2b6f22786b-20221128111122", | ||
"description": "", | ||
@@ -11,3 +11,3 @@ "main": "src/index.js", | ||
"postcss": "^8.4.16", | ||
"@rspack/binding": "0.0.0-28c9a9ca7c-20221122072855" | ||
"@rspack/binding": "0.0.0-2b6f22786b-20221128111122" | ||
}, | ||
@@ -14,0 +14,0 @@ "author": "", |
@@ -11,6 +11,7 @@ const { Processor } = require("postcss"); | ||
module.exports = async function loader(loaderContext) { | ||
module.exports = async function loader(content, sourceMap) { | ||
const callback = this.async(); | ||
// TODO: customize options, until js binding support this functionality | ||
// console.log(loaderContext.getOptions()); | ||
let options = loaderContext.getOptions() ?? {}; | ||
// console.log(this.getOptions()); | ||
let options = this.getOptions() ?? {}; | ||
let modulesOptions = options.modules; | ||
@@ -21,5 +22,5 @@ let pxToRem = options.pxToRem; | ||
? options.sourceMap | ||
: loaderContext.useSourceMap; | ||
: this.sourceMap; | ||
try { | ||
let meta = ""; | ||
let additionalData; | ||
let plugins = []; | ||
@@ -32,4 +33,4 @@ let enablePxToRem = false; | ||
let processOptions = { | ||
from: loaderContext.resourcePath, | ||
to: loaderContext.resourcePath | ||
from: this.resourcePath, | ||
to: this.resourcePath | ||
}; | ||
@@ -56,7 +57,7 @@ | ||
if (typeof auto === "boolean") { | ||
isModules = auto && IS_MODULES.test(loaderContext.resourcePath); | ||
isModules = auto && IS_MODULES.test(this.resourcePath); | ||
} else if (auto instanceof RegExp) { | ||
isModules = auto.test(loaderContext.resourcePath); | ||
isModules = auto.test(this.resourcePath); | ||
} else if (typeof auto === "function") { | ||
isModules = auto(loaderContext.resourcePath); | ||
isModules = auto(this.resourcePath); | ||
} | ||
@@ -71,3 +72,3 @@ delete modulesOptions.auto; | ||
if (json) { | ||
meta = json; | ||
additionalData = json; | ||
} | ||
@@ -86,28 +87,18 @@ } | ||
} | ||
if (loaderContext.sourceMap && processOptions.map) { | ||
processOptions.map.prev = normalizeSourceMap( | ||
loaderContext.sourceMap, | ||
loaderContext.context | ||
); | ||
if (sourceMap && processOptions.map) { | ||
processOptions.map.prev = normalizeSourceMap(sourceMap, this.context); | ||
} | ||
let root = new Processor(plugins); | ||
let res = await root.process( | ||
loaderContext.source.getCode(), | ||
processOptions | ||
); | ||
let res = await root.process(content, processOptions); | ||
let map = res.map ? res.map.toJSON() : undefined; | ||
if (map && useSourceMap) { | ||
map = normalizeSourceMapAfterPostcss(map, loaderContext.context); | ||
map = normalizeSourceMapAfterPostcss(map, this.context); | ||
} | ||
return { | ||
content: res.css, | ||
meta: meta ? Buffer.from(JSON.stringify(meta)) : "", | ||
sourceMap: map | ||
}; | ||
callback(null, res.css, map, additionalData); | ||
} catch (err) { | ||
throw new Error(err); | ||
callback(err, ""); | ||
} | ||
}; |
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
5843
155
+ Added@rspack/binding@0.0.0-2b6f22786b-20221128111122(transitive)
- Removed@rspack/binding@0.0.0-28c9a9ca7c-20221122072855(transitive)