postcss-load-config
Advanced tools
Comparing version 3.1.4 to 4.0.0
{ | ||
"name": "postcss-load-config", | ||
"version": "3.1.4", | ||
"version": "4.0.0", | ||
"description": "Autoload Config for PostCSS", | ||
@@ -11,3 +11,3 @@ "main": "src/index.js", | ||
"engines": { | ||
"node": ">= 10" | ||
"node": ">= 14" | ||
}, | ||
@@ -20,3 +20,3 @@ "funding": { | ||
"lilconfig": "^2.0.5", | ||
"yaml": "^1.10.2" | ||
"yaml": "^2.1.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "peerDependencies": { |
@@ -94,3 +94,12 @@ [![npm][npm]][npm-url] | ||
You may need some logic within your config. In this case create JS file named **`.postcssrc.js`** or **`postcss.config.js`** | ||
You may need some logic within your config. | ||
In this case create JS file named: | ||
- `.postcssrc.js` | ||
- `.postcssrc.mjs` | ||
- `.postcssrc.cjs` | ||
- `.postcssrc.ts` | ||
- `postcss.config.js` | ||
- `postcss.config.mjs` | ||
- `postcss.config.cjs` | ||
- `postcss.config.ts` | ||
@@ -101,4 +110,3 @@ ``` | ||
|– public | ||
| | ||
|- (.postcssrc.js|postcss.config.js) | ||
|- (.postcssrc|postcss.config).(js|mjs|cjs|ts) | ||
|- package.json | ||
@@ -329,4 +337,2 @@ ``` | ||
### `Async` | ||
```js | ||
@@ -349,17 +355,2 @@ const { readFileSync } = require('fs') | ||
### `Sync` | ||
```js | ||
const { readFileSync } = require('fs') | ||
const postcss = require('postcss') | ||
const postcssrc = require('postcss-load-config') | ||
const css = readFileSync('index.sss', 'utf8') | ||
const ctx = { parser: true, map: 'inline' } | ||
const { plugins, options } = postcssrc.sync(ctx) | ||
``` | ||
<div align="center"> | ||
@@ -366,0 +357,0 @@ <img width="80" height="80" halign="10" src="https://worldvectorlogo.com/logos/gulp.svg"> |
@@ -14,8 +14,2 @@ // based on @types/postcss-load-config@2.0.1 | ||
declare namespace postcssrc { | ||
function sync( | ||
ctx?: ConfigContext, | ||
path?: string, | ||
options?: ConfigOptions | ||
): Result; | ||
// In the ConfigContext, these three options can be instances of the | ||
@@ -22,0 +16,0 @@ // appropriate class, or strings. If they are strings, postcss-load-config will |
@@ -39,3 +39,3 @@ 'use strict' | ||
options: loadOptions(config, file), | ||
file: file | ||
file | ||
} | ||
@@ -70,2 +70,7 @@ } | ||
const importDefault = async filepath => { | ||
const module = await import(filepath) | ||
return module.default | ||
} | ||
const addTypeScriptLoader = (options = {}, loader) => { | ||
@@ -86,5 +91,7 @@ const moduleName = 'postcss' | ||
`.${moduleName}rc.cjs`, | ||
`.${moduleName}rc.mjs`, | ||
`${moduleName}.config.ts`, | ||
`${moduleName}.config.js`, | ||
`${moduleName}.config.cjs` | ||
`${moduleName}.config.cjs`, | ||
`${moduleName}.config.mjs` | ||
], | ||
@@ -95,2 +102,5 @@ loaders: { | ||
'.yml': (filepath, content) => yaml.parse(content), | ||
'.js': importDefault, | ||
'.cjs': importDefault, | ||
'.mjs': importDefault, | ||
'.ts': loader | ||
@@ -159,22 +169,2 @@ } | ||
rc.sync = withTypeScriptLoader((ctx, path, options) => { | ||
/** | ||
* @type {Object} The full Config Context | ||
*/ | ||
ctx = createContext(ctx) | ||
/** | ||
* @type {String} `process.cwd()` | ||
*/ | ||
path = path ? resolve(path) : process.cwd() | ||
const result = config.lilconfigSync('postcss', options).search(path) | ||
if (!result) { | ||
throw new Error(`No PostCSS Config found in: ${path}`) | ||
} | ||
return processResult(ctx, result) | ||
}) | ||
/** | ||
@@ -181,0 +171,0 @@ * Autoload Config for PostCSS |
@@ -1,2 +0,2 @@ | ||
// eslint-disable-next-line node/no-deprecated-api | ||
// eslint-disable-next-line n/no-deprecated-api | ||
const { createRequire, createRequireFromPath } = require('module') | ||
@@ -3,0 +3,0 @@ |
22282
333
492
+ Added@types/node@20.12.8(transitive)
+ Addedyaml@2.4.2(transitive)
- Removed@types/node@20.12.7(transitive)
- Removedyaml@1.10.2(transitive)
Updatedyaml@^2.1.0