From 00b06dd2c814aa0c02474c7156272be7794b4a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 1 Jan 2020 11:44:50 +0100 Subject: [PATCH] Adjust docs about new autoLabel values --- packages/babel-plugin-emotion/README.md | 14 ++++++++++---- packages/babel-preset-css-prop/README.md | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/babel-plugin-emotion/README.md b/packages/babel-plugin-emotion/README.md index 8fac9170d..7fef05cbb 100644 --- a/packages/babel-plugin-emotion/README.md +++ b/packages/babel-plugin-emotion/README.md @@ -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 } @@ -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: @@ -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** @@ -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 @@ -235,7 +241,7 @@ be prepended automatically. ```javascript // BrownView.js -// autoLabel: true +// autoLabel: 'dev-only' // labelFormat: '[filename]--[local]' const brownStyles = css({ color: 'brown' }) ``` diff --git a/packages/babel-preset-css-prop/README.md b/packages/babel-preset-css-prop/README.md index 78d8b1942..3b6360a4c 100644 --- a/packages/babel-preset-css-prop/README.md +++ b/packages/babel-preset-css-prop/README.md @@ -31,7 +31,7 @@ yarn add @emotion/babel-preset-css-prop + [ + "@emotion/babel-preset-css-prop", + { -+ "autoLabel": true, ++ "autoLabel": "dev-only", + "labelFormat": "[local]" + } + ] @@ -40,7 +40,7 @@ yarn add @emotion/babel-preset-css-prop - [ - "emotion", - { -- "autoLabel": true, +- "autoLabel": "dev-only", - "labelFormat": "[local]" - } - ] @@ -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