Skip to content

Commit 078ca9d

Browse files
docs: fix autoload config files (webpack-contrib#502)
1 parent 0a0ad6e commit 078ca9d

File tree

11 files changed

+201
-249
lines changed

11 files changed

+201
-249
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ The loader will search up the directory tree for configuration in the following
370370

371371
- a `postcss` property in `package.json`
372372
- a `.postcssrc` file in JSON or YAML format
373-
- a `.postcss.json`, `.postcss.yaml`, `.postcss.yml`, `.postcss.js`, or `.postcss.cjs` file
373+
- a `.postcssrc.json`, `.postcssrc.yaml`, `.postcssrc.yml`, `.postcssrc.js`, or `.postcssrc.cjs` file
374374
- a `postcss.config.js` or `postcss.config.cjs` CommonJS module exporting an object (**recommended**)
375375

376376
##### Examples of Config Files

package-lock.json

Lines changed: 140 additions & 242 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
"semver": "^7.3.2"
5050
},
5151
"devDependencies": {
52-
"@babel/cli": "^7.12.1",
53-
"@babel/core": "^7.12.3",
54-
"@babel/preset-env": "^7.12.1",
52+
"@babel/cli": "^7.12.8",
53+
"@babel/core": "^7.12.8",
54+
"@babel/preset-env": "^7.12.7",
5555
"@commitlint/cli": "^11.0.0",
5656
"@commitlint/config-conventional": "^11.0.0",
5757
"@webpack-contrib/defaults": "^6.3.0",
@@ -61,14 +61,14 @@
6161
"cssnano": "^4.1.10",
6262
"del": "^6.0.0",
6363
"del-cli": "^3.0.1",
64-
"eslint": "^7.13.0",
64+
"eslint": "^7.14.0",
6565
"eslint-config-prettier": "^6.15.0",
6666
"eslint-plugin-import": "^2.22.1",
6767
"husky": "^4.3.0",
6868
"jest": "^26.6.3",
6969
"less": "^3.12.2",
7070
"less-loader": "^7.1.0",
71-
"lint-staged": "^10.5.1",
71+
"lint-staged": "^10.5.2",
7272
"memfs": "^3.2.0",
7373
"midas": "^2.0.3",
7474
"npm-run-all": "^4.1.5",
@@ -78,7 +78,7 @@
7878
"postcss-js": "^3.0.3",
7979
"postcss-nested": "^5.0.1",
8080
"postcss-short": "^5.0.0",
81-
"prettier": "^2.1.2",
81+
"prettier": "^2.2.0",
8282
"sass": "^1.29.0",
8383
"sass-loader": "^10.1.0",
8484
"standard-version": "^9.0.0",

test/config-autoload.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ describe("autoload config", () => {
2626
);
2727
});
2828

29+
it('should load ".postcssrc.js"', async () => {
30+
const loadedConfig = await loadConfig(
31+
loaderContext,
32+
path.resolve(testDirectory, "rc-js")
33+
);
34+
35+
expect(loadedConfig.config.map).toEqual(false);
36+
expect(loadedConfig.config.from).toEqual("./test/rc-js/fixtures/index.css");
37+
expect(loadedConfig.config.to).toEqual("./test/rc-js/expect/index.css");
38+
expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
39+
expect(loadedConfig.filepath).toEqual(
40+
path.resolve(testDirectory, "rc-js", ".postcssrc.js")
41+
);
42+
});
43+
2944
it('should load "package.json"', async () => {
3045
const loadedConfig = await loadConfig(
3146
loaderContext,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
"parser": "sugarss",
3+
"syntax": "sugarss",
4+
"map": false,
5+
"from": "./test/rc-js/fixtures/index.css",
6+
"to": "./test/rc-js/expect/index.css",
7+
"plugins": [
8+
"postcss-import",
9+
["postcss-nested", {}]
10+
]
11+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.import {
2+
color: red;
3+
}
4+
5+
.test {
6+
color: blue;
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.import {
2+
color: red
3+
}
4+
5+
.test {
6+
color: blue
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.import {
2+
color: red;
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.import
2+
color: red
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import "imports/section.css";
2+
3+
.test {
4+
color: blue;
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@import "imports/section.sss"
2+
3+
.test
4+
color: blue

0 commit comments

Comments
 (0)