Skip to content

Commit

Permalink
Fix env variable nam
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 24, 2019
1 parent d612e27 commit d654c01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ This is why it is disabled by default.
First, you need to enable Grid prefixes by using either the `grid: "autoplace"`
option or the `/* autoprefixer grid: autoplace */` control comment.
Also you can use environment variable to enable Grid:
`AUTOPREFIX_GRID=autoplace npm build`.
`AUTOPREFIXER_GRID=autoplace npm build`.

Second, you need to test every fix with Grid in IE. It is not an enable and
forget feature, but it is still very useful.
Expand Down Expand Up @@ -615,7 +615,7 @@ to increase performance.

## Environment Variables

* `AUTOPREFIX_GRID`: (`autoplace`|`no-autoplace`) should Autoprefixer
* `AUTOPREFIXER_GRID`: (`autoplace`|`no-autoplace`) should Autoprefixer
add IE 10-11 prefixes for Grid Layout properties?
* `autoplace`: enable Autoprefixer grid translations
and *include* autoplacement support.
Expand All @@ -628,7 +628,7 @@ For instance, in Create React App.
Add variable before CLI command, which will build your CSS:

```sh
AUTOPREFIX_GRID=autoplace npm build
AUTOPREFIXER_GRID=autoplace npm build
```

See also [Browserslist environment variables].
Expand All @@ -637,12 +637,18 @@ See also [Browserslist environment variables].

## Grid Autoplacement support in IE

If the `grid` option is set to `"autoplace"`, limited autoplacement support is added to Autoprefixers grid translations. You can also use the `/* autoprefixer grid: autoplace */` control comment or `AUTOPREFIX_GRID=autoplace npm build`
environment variable.
If the `grid` option is set to `"autoplace"`, limited autoplacement support is added to Autoprefixers grid translations. You can also use
the `/* autoprefixer grid: autoplace */` control comment or
`AUTOPREFIXER_GRID=autoplace npm build` environment variable.

Autoprefixer will only autoplace grid cells if both `grid-template-rows` and `grid-template-columns` has been set. If `grid-template` or `grid-template-areas` has been set, Autoprefixer will use area based cell placement instead.
Autoprefixer will only autoplace grid cells if both `grid-template-rows`
and `grid-template-columns` has been set. If `grid-template`
or `grid-template-areas` has been set, Autoprefixer will use area based
cell placement instead.

Autoprefixer supports autoplacement by using `nth-child` CSS selectors. It creates [number of columns] x [number of rows] `nth-child` selectors. For this reason Autoplacement is only supported within the explicit grid.
Autoprefixer supports autoplacement by using `nth-child` CSS selectors.
It creates [number of columns] x [number of rows] `nth-child` selectors.
For this reason Autoplacement is only supported within the explicit grid.

```css
/* Input CSS */
Expand Down
8 changes: 6 additions & 2 deletions lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,12 @@ class Processor {
}
} else if (typeof this.prefixes.options.grid !== 'undefined') {
value = this.prefixes.options.grid
} else if (typeof process.env.AUTOPREFIX_GRID !== 'undefined') {
value = process.env.AUTOPREFIX_GRID === 'autoplace' ? 'autoplace' : true
} else if (typeof process.env.AUTOPREFIXER_GRID !== 'undefined') {
if (process.env.AUTOPREFIXER_GRID === 'autoplace') {
value = 'autoplace'
} else {
value = true
}
} else {
value = false
}
Expand Down
4 changes: 2 additions & 2 deletions test/autoprefixer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const COMMONS = [
]

afterEach(() => {
delete process.env.AUTOPREFIX_GRID
delete process.env.AUTOPREFIXER_GRID
})

it('throws on wrong options', () => {
Expand Down Expand Up @@ -479,7 +479,7 @@ it('has different outputs for different grid options', () => {

it('has different outputs for different grid environment variables', () => {
function ap (gridValue) {
process.env.AUTOPREFIX_GRID = gridValue
process.env.AUTOPREFIXER_GRID = gridValue
return autoprefixer({ overrideBrowserslist: ['Edge 12', 'IE 10'] })
}
let input = read('grid-options')
Expand Down

0 comments on commit d654c01

Please sign in to comment.