Skip to content

8.0.0 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
index.*.js
/index.*
package-lock.json
*.log*
*.result.css
25 changes: 20 additions & 5 deletions .rollup.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import babel from 'rollup-plugin-babel';

export default {
input: 'index.js',
input: 'src/index.js',
output: [
{ file: 'index.cjs.js', format: 'cjs' },
{ file: 'index.es.js', format: 'es' }
{ file: 'index.cjs.js', format: 'cjs', sourcemap: true, strict: false },
{ file: 'index.esm.mjs', format: 'esm', sourcemap: true, strict: false }
],
plugins: [
babel({
plugins: [
['@babel/plugin-syntax-import-meta']
],
presets: [
['@babel/env', { modules: false, targets: { node: 6 } }]
['@babel/preset-env', { modules: false, targets: { node: 8 } }]
]
})
}),
patchBabelPluginSyntaxImportMeta()
]
};

function patchBabelPluginSyntaxImportMeta () {
return {
name: 'patch-babel-plugin-syntax-import-meta',
renderChunk (code) {
const requireMatch = /new \(require\('u' \+ 'rl'\)\.URL\)/;

return code.replace(requireMatch, 'new url.URL');
}
};
}
106 changes: 79 additions & 27 deletions .tape.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,83 @@
module.exports = {
'postcss-normalize': {
'basic': {
message: 'supports basic usage'
},
'basic:last-2': {
message: 'supports { browsers: "last 2 versions" }',
options: {
browsers: 'last 2 versions'
}
},
'basic:last-1': {
message: 'supports { browsers: "last 1 versions" }',
options: {
browsers: 'last 1 versions'
}
},
'insertion-after': {
message: 'support an insertion point (at the end of the file)'
},
'insertion-duplicate': {
message: 'removes duplicate insertion points'
},
'option-force-import': {
message: 'forces an import at the beginning of the file',
options: {
forceImport: true
}
/* Test Basic Usage */
'basic-normalize': {
message: 'supports @import-normalize usage'
},
'basic-sanitize': {
message: 'supports @import-sanitize usage'
},

/* Test @import Usage */
'import-normalize': {
message: 'supports @import "normalize" usage',
expect: "normalize.expect.css"
},
'import-normalize-opinionated': {
message: 'supports @import "normalize/opinionated" usage'
},
'import-sanitize': {
message: 'supports @import "sanitize" usage',
expect: "sanitize.expect.css"
},
'import-sanitize-forms': {
message: 'supports @import "sanitize/forms" usage'
},
'import-sanitize-all': {
message: 'supports @import "sanitize/*" + (forms + page + typography) usage'
},

/* Test { browsers } Usage */
'browsers-normalize': {
message: 'supports { browsers: "last 2 * versions, not EdgeHTML" }',
options: {
browsers: 'last 2 chrome versions, edge >= 72, last 2 firefox versions, last 2 safari versions, last 1 ios versions, last 1 android versions'
}
},

/* Test { forceImport } Usage */
'force-normalize': {
message: 'supports { forceImport: true }',
options: {
forceImport: true
}
},
'force-sanitize': {
message: 'supports { forceImport: "sanitize" }',
options: {
forceImport: 'sanitize'
}
},
'force-sanitize-all': {
message: 'supports { forceImport: "sanitize/*" }',
options: {
forceImport: 'sanitize/*'
}
},

/* Test { allowDuplicates } Usage */
'duplicates': {
message: 'supports preventing duplicates'
},
'duplicates:allow': {
message: 'supports allowing duplicates { allowDuplicates: true }',
options: {
allowDuplicates: true
}
},

/* Test PostCSS Import Usage */
'postcss-import': {
message: 'supports PostCSS Import Usage',
source: 'import-normalize.css',
expect: 'import-normalize.expect.css',
plugin: (() => {
const postcss = require('postcss');
const postcssImport = require('postcss-import');
const postcssNormalize = require('.');

const plugin = postcss([ postcssImport(postcssNormalize().postcssImport()) ]);

return plugin;
})()
}
};
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
language: node_js

node_js:
- 6
- 8

install:
- npm install --ignore-scripts
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changes to PostCSS Normalize

### 8.0.0 (June 3, 2019)

- Added: `sanitize.css` 10.0.0 (major)
- Updated: `@csstools/normalize.css` to 10.1.0 (major)
- Updated: `browserslist` to 4.5.6 (minor)
- Updated: `postcss` to 7.0.16 (patch)
- Updated: Node 8+ compatibility (major)

### 7.0.1 (August 24, 2018)

- Use postcss-browser-comments v2.0.0 (major, but a patch for this project)
11 changes: 7 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -89,17 +89,20 @@ module.exports = {

## Create React App

Create React App, starting from **v3.0.0**, [natively](https://facebook.github.io/create-react-app/docs/adding-css-reset) supports postcss-normalize. To start using it, simply add
Starting from **v3.0.0**,
[Create React App already includes postcss-normalize](https://facebook.github.io/create-react-app/docs/adding-css-reset).
To start using it, use the `@import-normalize` rule:

```
```pcss
// index.css

@import-normalize;
```

If you're using ***older versions*** of Create React App, follow these instructions:
---

Add [React App Rewired] and [React App Rewire PostCSS] to your project:
If you're using an ***older version*** of Create React App, add
[React App Rewired] and [React App Rewire PostCSS] to your project:

```bash
npm install react-app-rewired react-app-rewire-postcss --save-dev
113 changes: 79 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,17 +4,29 @@
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]

[PostCSS Normalize] lets you use the parts of [normalize.css] you need from
your [browserslist].
[PostCSS Normalize] lets you use the parts of [normalize.css] or [sanitize.css]
that you need from your [browserslist].

Use `@import-normalize` to determine where [normalize.css] rules should be
included. Duplicate `@import-normalize` rules will be removed. See all the
[Options] for more information.
```css
@import "normalize.css";
```

**PostCSS Normalize** uses the non-opinionated version of [normalize.css], but
the opinionated version can also be used. See [CSS Libraries] for more details.

```css
@import "normalize.css/opinionated.css";
```

Alternatively, use `@import-normalize` or `@import-sanizie` to avoid conflicts
with other `@import` transforms.

```pcss
@import-normalize;
@import-sanitize;
```

### Examples

Results when [browserslist] is `last 3 versions`:

```css
@@ -48,12 +60,6 @@ img {
}
```

---

[PostCSS Normalize] uses the non-opinionated version of [normalize.css].

---

## Usage

Add [PostCSS Normalize] to your project:
@@ -73,63 +79,102 @@ Add a [browserslist] entry in `package.json`:
Use [PostCSS Normalize] to process your CSS:

```js
import postcssNormalize from 'postcss-normalize';
const postcssNormalize = require('postcss-normalize')

postcssNormalize.process(YOUR_CSS /*, processOptions, pluginOptions */);
postcssNormalize.process(YOUR_CSS /*, processOptions, pluginOptions */)
```

Or use it as a [PostCSS] plugin:

```js
import postcss from 'postcss';
import postcssNormalize from 'postcss-normalize';
const postcss = require('postcss')
const postcssNormalize = require('postcss-normalize')

postcss([
postcssNormalize(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
]).process(YOUR_CSS /*, processOptions */)
```

[PostCSS Normalize] runs in all Node environments, with special instructions for:

| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
| --- | --- | --- | --- | --- | --- |

## PostCSS Import Usage

```js
const postcss = require('postcss')
const postcssImport = require('postcss-import')
const postcssNormalize = require('postcss-normalize')

postcss([
postcssImport(
postcssNormalize(
/* pluginOptions (for PostCSS Normalize) */
).postcssImport(
/* pluginOptions (for PostCSS Import) */
)
)
])
```

## Options

### allowDuplicates

Allows you to insert multiple, duplicate insertions of [normalize.css] rules.
The default is `false`.
The `allowDuplicates` option determines whether multiple, duplicate insertions
of CSS libraries are allowed. By default, duplicate libraries are omitted.

```js
postcssNormalize({
allowDuplicates: true
});
postcssNormalize({ allowDuplicates: true })
```

### browsers
### forceImport

Allows you to override of the project’s [browserslist] for [PostCSS Normalize].
The default is `false`.
The `forceImport` option defines CSS libraries that will be inserted at the
beginning of the CSS file. Unless overriden by `allowDuplicates`, duplicate
CSS libraries would still be omitted.

```js
postcssNormalize({ forceImport: true })
```

Specific CSS libraries may be defined.

```js
postcssNormalize({
browsers: 'last 2 versions'
});
forceImport: 'sanitize.css'
})
```

### forceImport
### browsers

Allows you to force an insertion of [normalize.css] rules at the beginning of
the CSS file if no insertion point is specified. The default is `false`.
The `browsers` option defines an override of the project’s [browserslist] for
[PostCSS Normalize]. This option should be avoided in leui of a browserslist
file.

```js
postcssNormalize({
forceImport: true
});
postcssNormalize({ browsers: 'last 2 versions' })
```

---

## CSS Libraries

**PostCSS Normalize** can include [normalize.css] or [sanitize.css] and
configure either in the following combinations:

```css
@import "normalize"; /* also, @import "normalize.css" */
@import "normalize/opinionated"; /* also, @import "normalize.css/opinionated.css", @import "normalize.css/*" */
@import "sanitize"; /* also, @import "sanitize.css" */
@import "sanitize/forms"; /* also, @import "sanitize.css/forms.css" */
@import "sanitize/typography"; /* also, @import "sanitize.css/typography.css" */
@import "sanitize/page"; /* also, @import "sanitize.css/page.css" */
@import "sanitize/*"; /* also, @import "sanitize.css/*" (sanitize + all additions) */
```

[cli-img]: https://img.shields.io/travis/csstools/postcss-normalize.svg
[cli-img]: https://img.shields.io/travis/csstools/postcss-normalize/master.svg
[cli-url]: https://travis-ci.org/csstools/postcss-normalize
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/postcss/postcss
Loading