Skip to content

Commit 5c5b70a

Browse files
committed
6.0.0
1 parent a68c2d5 commit 5c5b70a

17 files changed

+1492
-968
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes to PostCSS Normalize
22

3+
### 6.0.0 (June 16, 2018)
4+
5+
- Use normalize.css v8 (major)
6+
- Include normalize.css comments
7+
- Include normalize.css sourcemap
8+
39
### 5.0.0 (June 7, 2018)
410

511
- Update `browserslist` to v3.2.8 (major)

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ scope and avoid unrelated commits.
2626
cd postcss-normalize
2727

2828
# Assign the original repo to a remote called "upstream"
29-
git remote add upstream git@github.com:jonathantneal/postcss-normalize.git
29+
git remote add upstream git@github.com:csstools/postcss-normalize.git
3030

3131
# Install the tools necessary for testing
3232
npm install

INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Installing PostCSS Normalize
22

3-
$[PostCSS Normalize] runs in all Node environments, with special instructions for:
3+
[PostCSS Normalize] runs in all Node environments, with special instructions for:
44

55
| [Node](#node) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) |
66
| --- | --- | --- | --- | --- |
@@ -144,6 +144,6 @@ grunt.initConfig({
144144
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
145145
[PostCSS]: https://github.com/postcss/postcss
146146
[PostCSS Loader]: https://github.com/postcss/postcss-loader
147-
[PostCSS Normalize]: https://github.com/jonathantneal/postcss-normalize
147+
[PostCSS Normalize]: https://github.com/csstools/postcss-normalize
148148
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
149149
[React App Rewired]: https://github.com/timarney/react-app-rewired

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Use `@import-normalize` to determine where [normalize.css] rules should be
1111
included. Duplicate `@import-normalize` rules will be removed. See all the
1212
[Options] for more information.
1313

14-
```css
14+
```pcss
1515
@import-normalize;
1616
```
1717

@@ -129,15 +129,15 @@ postcssNormalize({
129129
});
130130
```
131131

132-
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-normalize.svg
133-
[cli-url]: https://travis-ci.org/jonathantneal/postcss-normalize
132+
[cli-img]: https://img.shields.io/travis/csstools/postcss-normalize.svg
133+
[cli-url]: https://travis-ci.org/csstools/postcss-normalize
134134
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
135135
[git-url]: https://gitter.im/postcss/postcss
136136
[npm-img]: https://img.shields.io/npm/v/postcss-normalize.svg
137137
[npm-url]: https://www.npmjs.com/package/postcss-normalize
138138

139139
[browserslist]: http://browserl.ist/
140-
[normalize.css]: https://github.com/jonathantneal/normalize.css
141-
[Options]: #Options
140+
[normalize.css]: https://github.com/csstools/normalize.css
141+
[Options]: #options
142142
[PostCSS]: https://github.com/postcss/postcss
143-
[PostCSS Normalize]: https://github.com/jonathantneal/postcss-normalize
143+
[PostCSS Normalize]: https://github.com/csstools/postcss-normalize

index.js

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,58 @@
1-
// tooling
2-
const browserslist = require('browserslist');
3-
const normalizeRules = require('./lib/normalize.js');
4-
const postcss = require('postcss');
1+
import postcss from 'postcss';
2+
import postcssBrowserComments from 'postcss-browser-comments';
3+
import fs from 'fs';
54

6-
// plugin
7-
module.exports = postcss.plugin('postcss-normalize', (opts) => {
8-
return (root) => {
9-
// client browser list
10-
const clientBrowserList = browserslist(opts && opts.browsers, {
11-
path: root.source && root.source.input && root.source.input.file
12-
});
5+
export default postcss.plugin('postcss-normalize', opts => {
6+
const parsedNormalize = parseNormalize(opts);
137

14-
// applied rules from normalize
15-
const appliedRules = normalizeRules.map(
16-
(rule) => {
17-
const clone = rule.clone();
18-
19-
clone.nodes = clone.nodes.filter(
20-
(decl, index) => {
21-
// whether the declaration browser list matches the client browser list
22-
return clientBrowserList.some(
23-
(clientBrowser) => browserslist(rule.nodes[index].browserList).some(
24-
(declBrowser) => declBrowser === clientBrowser
25-
)
26-
);
27-
}
28-
);
29-
30-
return clone;
31-
}
32-
).filter(
33-
(rule) => rule.nodes.length
34-
);
8+
return async root => {
9+
const normalizeRoot = await parsedNormalize;
3510

3611
// use @import postcss-normalize insertion point
3712
root.walkAtRules(
3813
'import-normalize',
39-
(atrule) => {
14+
atrule => {
4015
if (opts && opts.allowDuplicates) {
4116
// use any insertion point
42-
atrule.replaceWith(
43-
appliedRules.map(
44-
(rule) => rule.clone()
45-
)
46-
);
47-
} else if (appliedRules[0].parent) {
17+
atrule.replaceWith(normalizeRoot);
18+
} else if (normalizeRoot.parent) {
4819
// remove duplicate insertions
4920
atrule.remove();
5021
} else {
5122
// use the first insertion point
52-
atrule.replaceWith(appliedRules);
23+
atrule.replaceWith(normalizeRoot);
5324
}
5425
}
5526
);
5627

57-
if (opts && opts.forceImport && !appliedRules[0].parent) {
28+
if (opts && opts.forceImport && !normalizeRoot.parent) {
5829
// prepend required normalize rules
59-
root.prepend(appliedRules);
30+
root.prepend(normalizeRoot);
6031
}
6132
};
6233
});
34+
35+
function parseNormalize(opts) {
36+
const from = require.resolve('@csstools/normalize.css');
37+
const postcssBrowserCommentsParser = postcssBrowserComments(opts);
38+
39+
return new Promise(
40+
(resolve, reject) => fs.readFile(from, 'utf8',
41+
(err, res) => {
42+
if (err) {
43+
reject(err);
44+
} else {
45+
resolve(res);
46+
}
47+
}
48+
)
49+
).then(
50+
css => postcss.parse(css, { from })
51+
).then(
52+
root => {
53+
postcssBrowserCommentsParser(root);
54+
55+
return root;
56+
}
57+
);
58+
}

lib/normalize-browser-list.json

Lines changed: 0 additions & 67 deletions
This file was deleted.

lib/normalize-init.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)