Skip to content

Commit

Permalink
Adjust docs about new autoLabel values
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Jan 1, 2020
1 parent 6f9aac2 commit 00b06dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions packages/babel-plugin-emotion/README.md
Expand Up @@ -132,7 +132,7 @@ _Defaults Shown_
{
// sourceMap is on by default but source maps are dead code eliminated in production
"sourceMap": true,
"autoLabel": process.env.NODE_ENV !== 'production',
"autoLabel": "dev-only",
"labelFormat": "[local]",
"cssPropOptimization": true
}
Expand Down Expand Up @@ -183,7 +183,7 @@ This option enables the following:
### `autoLabel`

`boolean`, defaults to `process.env.NODE_ENV !== 'production'`.
`'dev-only' | 'always' | 'never'`, , defaults to `dev-only`.

This option enables the following:

Expand All @@ -194,6 +194,12 @@ This option enables the following:
(Eg. `iconStyles$1` will become `iconStyles1`) because `$` is not valid
[CSS ClassName Selector](https://stackoverflow.com/questions/448981/which-characters-are-valid-in-css-class-names-selectors#449000)

Each possible value for this option produces different output code:

- with `dev-only` we optimize the production code, so there are no labels added there, but at the same time we keep labels for development environments,
- with `always` we always add labels when possible,
- with `never` we disable this entirely and no labels are added.

#### css

**In**
Expand All @@ -214,7 +220,7 @@ const brownStyles = /*#__PURE__*/ css({ color: 'brown' }, 'label:brownStyles;')

`string`, defaults to `"[local]"`.

This option only works when `autoLabel` is set to `true`. It allows you to
This option only works when `autoLabel` is set to `'dev-only'` or `'always'`. It allows you to
define the format of the resulting `label`. The format is defined via string where
variable parts are enclosed in square brackets `[]`.
For example `labelFormat: "my-classname--[local]"`, where `[local]` will be replaced
Expand All @@ -235,7 +241,7 @@ be prepended automatically.

```javascript
// BrownView.js
// autoLabel: true
// autoLabel: 'dev-only'
// labelFormat: '[filename]--[local]'
const brownStyles = css({ color: 'brown' })
```
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-preset-css-prop/README.md
Expand Up @@ -31,7 +31,7 @@ yarn add @emotion/babel-preset-css-prop
+ [
+ "@emotion/babel-preset-css-prop",
+ {
+ "autoLabel": true,
+ "autoLabel": "dev-only",
+ "labelFormat": "[local]"
+ }
+ ]
Expand All @@ -40,7 +40,7 @@ yarn add @emotion/babel-preset-css-prop
- [
- "emotion",
- {
- "autoLabel": true,
- "autoLabel": "dev-only",
- "labelFormat": "[local]"
- }
- ]
Expand Down Expand Up @@ -146,7 +146,7 @@ Options for both `babel-plugin-emotion` and `@babel/plugin-transform-react-jsx`
"presets": [
"@emotion/babel-preset-css-prop",
{
"autoLabel": true,
"autoLabel": "dev-only",
"labelFormat": "[local]",
"useBuiltIns": false,
"throwIfNamespace": true
Expand Down

0 comments on commit 00b06dd

Please sign in to comment.