postcss-modules
Advanced tools
Comparing version 4.1.3 to 4.2.0
@@ -112,4 +112,12 @@ "use strict"; | ||
const loader = getLoader(opts, loaderPlugins); | ||
const parser = new _parser2.default(loader.fetch.bind(loader)); | ||
const fetcher = function fetcher(file, relativeTo, depTrace) { | ||
const resolvedResult = typeof opts.resolve === 'function' && opts.resolve(file); | ||
const resolvedFile = resolvedResult instanceof Promise ? resolvedResult : Promise.resolve(resolvedResult); | ||
return resolvedFile.then(function (f = file) { | ||
return loader.fetch.call(loader, f || file, relativeTo, depTrace); | ||
}); | ||
}; | ||
const parser = new _parser2.default(fetcher); | ||
yield (0, _postcss2.default)([...pluginList, parser.plugin()]).process(css, { | ||
@@ -116,0 +124,0 @@ from: inputFile |
# Changelog | ||
## 4.2.0 | ||
- Added the `resolve` option to configure lookup paths for composes/from by @kamilic https://github.com/madyankin/postcss-modules/pull/126 | ||
## 4.1.3 | ||
@@ -4,0 +8,0 @@ |
@@ -51,2 +51,4 @@ import type { Plugin } from "postcss"; | ||
Loader?: typeof Loader; | ||
resolve?: (file: string) => string | Promise<string>; | ||
} | ||
@@ -53,0 +55,0 @@ |
{ | ||
"name": "postcss-modules", | ||
"version": "4.1.3", | ||
"version": "4.2.0", | ||
"description": "PostCSS plugin to use CSS Modules everywhere", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -8,4 +8,12 @@ # postcss-modules | ||
What is this? For example, you have the following CSS: | ||
## Support the developer | ||
I maintain the plugin in my free time, so I don't receive any payment for this work. | ||
To have better docs, new features and integrations with frameworks, you can [support me on Patreon](https://www.patreon.com/bePatron?u=25976212). | ||
## What is this? | ||
For example, you have the following CSS: | ||
```css | ||
@@ -207,2 +215,20 @@ /* styles.css */ | ||
### Resolve path alias | ||
You can rewrite paths for `composes/from` by using `resolve` options. | ||
It's useful when you need to resolve custom path alias. | ||
```js | ||
postcss([ | ||
require("postcss-modules")({ | ||
resolve: function (file) { | ||
return file.replace(/^@/, process.cwd()); | ||
}, | ||
}), | ||
]); | ||
``` | ||
`resolve` may also return a `Promise<string>`. | ||
## Integration with templates | ||
@@ -209,0 +235,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
31111
400
328
0