postcss-modules 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +10 -17
- package/build/index.js +29 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- [`localsConvention` option](https://github.com/css-modules/postcss-modules#localsconvention) by Hamza Mihai Daniel (@allocenx) <https://github.com/css-modules/postcss-modules/pull/103>, <https://github.com/css-modules/postcss-modules/issues/93>
|
|
8
|
+
|
|
9
|
+
### Breaking changes
|
|
10
|
+
|
|
11
|
+
- `camelCase` camelCase removed, use the [`localsConvention` option](https://github.com/css-modules/postcss-modules#localsconvention) instead.
|
|
12
|
+
|
|
3
13
|
## 1.5.0
|
|
4
14
|
|
|
5
15
|
- Added `hashPrefix` option by Jesse Thomson (@jessethomson) <https://github.com/css-modules/postcss-modules/pull/98>
|
package/README.md
CHANGED
|
@@ -181,26 +181,19 @@ postcss([
|
|
|
181
181
|
]);
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
-
###
|
|
184
|
+
### localsConvention
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
Type: `String`
|
|
187
|
+
Default: `null`
|
|
187
188
|
|
|
188
|
-
|
|
189
|
+
Style of exported classnames.
|
|
189
190
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
JSON:
|
|
197
|
-
|
|
198
|
-
```json
|
|
199
|
-
{
|
|
200
|
-
"post-title": "._post-title_116zl_1",
|
|
201
|
-
"postTitle": "._post-title_116zl_1"
|
|
202
|
-
}
|
|
203
|
-
```
|
|
191
|
+
| Name | Type | Description |
|
|
192
|
+
| :-------------------: | :--------: | :----------------------------------------------------------------------------------------------- |
|
|
193
|
+
| **`'camelCase'`** | `{String}` | Class names will be camelized, the original class name will not to be removed from the locals |
|
|
194
|
+
| **`'camelCaseOnly'`** | `{String}` | Class names will be camelized, the original class name will be removed from the locals |
|
|
195
|
+
| **`'dashes'`** | `{String}` | Only dashes in class names will be camelized |
|
|
196
|
+
| **`'dashesOnly'`** | `{String}` | Dashes in class names will be camelized, the original class name will be removed from the locals |
|
|
204
197
|
|
|
205
198
|
## Integration with templates
|
|
206
199
|
|
package/build/index.js
CHANGED
|
@@ -79,6 +79,10 @@ function isResultPlugin(plugin) {
|
|
|
79
79
|
return plugin.postcssPlugin !== PLUGIN_NAME;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
function dashesCamelCase(string) {
|
|
83
|
+
return string.replace(/-+(\w)/g, (_, firstLetter) => firstLetter.toUpperCase());
|
|
84
|
+
}
|
|
85
|
+
|
|
82
86
|
module.exports = _postcss2.default.plugin(PLUGIN_NAME, (opts = {}) => {
|
|
83
87
|
const getJSON = opts.getJSON || _saveJSON2.default;
|
|
84
88
|
|
|
@@ -98,11 +102,31 @@ module.exports = _postcss2.default.plugin(PLUGIN_NAME, (opts = {}) => {
|
|
|
98
102
|
const out = loader.finalSource;
|
|
99
103
|
if (out) css.prepend(out);
|
|
100
104
|
|
|
101
|
-
if (opts.
|
|
102
|
-
Object.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
if (opts.localsConvention) {
|
|
106
|
+
parser.exportTokens = Object.entries(parser.exportTokens).reduce(function (tokens, [className, value]) {
|
|
107
|
+
switch (opts.localsConvention) {
|
|
108
|
+
case "camelCase":
|
|
109
|
+
tokens[className] = value;
|
|
110
|
+
tokens[(0, _lodash2.default)(className)] = value;
|
|
111
|
+
|
|
112
|
+
break;
|
|
113
|
+
case "camelCaseOnly":
|
|
114
|
+
tokens[(0, _lodash2.default)(className)] = value;
|
|
115
|
+
|
|
116
|
+
break;
|
|
117
|
+
case "dashes":
|
|
118
|
+
tokens[className] = value;
|
|
119
|
+
tokens[dashesCamelCase(className)] = value;
|
|
120
|
+
|
|
121
|
+
break;
|
|
122
|
+
case "dashesOnly":
|
|
123
|
+
tokens[dashesCamelCase(className)] = value;
|
|
124
|
+
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return tokens;
|
|
129
|
+
}, {});
|
|
106
130
|
}
|
|
107
131
|
|
|
108
132
|
result.messages.push({
|