Skip to content

Commit

Permalink
docs: fix autoload config files (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Nov 24, 2020
1 parent 0a0ad6e commit 078ca9d
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 249 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ The loader will search up the directory tree for configuration in the following

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

##### Examples of Config Files
Expand Down
382 changes: 140 additions & 242 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"semver": "^7.3.2"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/cli": "^7.12.8",
"@babel/core": "^7.12.8",
"@babel/preset-env": "^7.12.7",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@webpack-contrib/defaults": "^6.3.0",
Expand All @@ -61,14 +61,14 @@
"cssnano": "^4.1.10",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"eslint": "^7.13.0",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"husky": "^4.3.0",
"jest": "^26.6.3",
"less": "^3.12.2",
"less-loader": "^7.1.0",
"lint-staged": "^10.5.1",
"lint-staged": "^10.5.2",
"memfs": "^3.2.0",
"midas": "^2.0.3",
"npm-run-all": "^4.1.5",
Expand All @@ -78,7 +78,7 @@
"postcss-js": "^3.0.3",
"postcss-nested": "^5.0.1",
"postcss-short": "^5.0.0",
"prettier": "^2.1.2",
"prettier": "^2.2.0",
"sass": "^1.29.0",
"sass-loader": "^10.1.0",
"standard-version": "^9.0.0",
Expand Down
15 changes: 15 additions & 0 deletions test/config-autoload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ describe("autoload config", () => {
);
});

it('should load ".postcssrc.js"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
path.resolve(testDirectory, "rc-js")
);

expect(loadedConfig.config.map).toEqual(false);
expect(loadedConfig.config.from).toEqual("./test/rc-js/fixtures/index.css");
expect(loadedConfig.config.to).toEqual("./test/rc-js/expect/index.css");
expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
expect(loadedConfig.filepath).toEqual(
path.resolve(testDirectory, "rc-js", ".postcssrc.js")
);
});

it('should load "package.json"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/config-autoload/rc-js/.postcssrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
"parser": "sugarss",
"syntax": "sugarss",
"map": false,
"from": "./test/rc-js/fixtures/index.css",
"to": "./test/rc-js/expect/index.css",
"plugins": [
"postcss-import",
["postcss-nested", {}]
]
};
7 changes: 7 additions & 0 deletions test/fixtures/config-autoload/rc-js/expect/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.import {
color: red;
}

.test {
color: blue;
}
7 changes: 7 additions & 0 deletions test/fixtures/config-autoload/rc-js/expect/index.sss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.import {
color: red
}

.test {
color: blue
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.import {
color: red;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.import
color: red
5 changes: 5 additions & 0 deletions test/fixtures/config-autoload/rc-js/fixtures/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "imports/section.css";

.test {
color: blue;
}
4 changes: 4 additions & 0 deletions test/fixtures/config-autoload/rc-js/fixtures/index.sss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import "imports/section.sss"

.test
color: blue

0 comments on commit 078ca9d

Please sign in to comment.