postcss-modules 5.0.0 → 6.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 +87 -52
- package/README.md +77 -70
- package/build/FileSystemLoader.js +140 -0
- package/build/{css-loader-core/parser.js → Parser.js} +16 -12
- package/build/fs.js +24 -0
- package/build/index.js +8 -152
- package/build/localsConvention.js +47 -0
- package/build/pluginFactory.js +107 -0
- package/build/saveJSON.js +5 -2
- package/build/{behaviours.js → scoping.js} +34 -5
- package/build/{unquote/index.js → unquote.js} +1 -1
- package/index.d.ts +24 -36
- package/package.json +2 -2
- package/build/css-loader-core/loader.js +0 -131
- package/build/generateScopedName.js +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,191 +1,226 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
The `resolve` option has two parameters now and can return `null`. Thanks to Rene Haas (@KingSora)
|
|
8
|
+
https://github.com/madyankin/postcss-modules/commit/86d8135cb5014d0b2848ef395608ee74d82bd179
|
|
9
|
+
|
|
10
|
+
Parameters:
|
|
11
|
+
|
|
12
|
+
- `file` — a module we want to resolve
|
|
13
|
+
- `importer` — the file that imports the module we want to resolve
|
|
14
|
+
|
|
15
|
+
Return value: `string | null | Promise<string | null>`
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
postcss([
|
|
19
|
+
require("postcss-modules")({
|
|
20
|
+
resolve: function (file, importer) {
|
|
21
|
+
return path.resolve(
|
|
22
|
+
path.dirname(importer),
|
|
23
|
+
file.replace(/^@/, process.cwd()
|
|
24
|
+
);
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
]);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- #140 "'Failed to obtain root' error on Windows" fixed by Pierre LeMoine (@DrInfiniteExplorer) https://github.com/madyankin/postcss-modules/pull/144
|
|
33
|
+
|
|
34
|
+
### Improved
|
|
35
|
+
|
|
36
|
+
- `icss-replace-symbols` replaced with with `icss-utils` by Jason Quense (@jquense). The updated replacer works better and will replace values in selectors, which didn't work until now. https://github.com/madyankin/postcss-modules/pull/145
|
|
37
|
+
|
|
3
38
|
## 5.0.0
|
|
4
39
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
40
|
+
- Fixed `composes` on Windows by @sapphi-red https://github.com/madyankin/postcss-modules/pull/135
|
|
41
|
+
- Updated Babel to v7 by @sapphi-red. Minimal supported version of Node.js is 10 from now https://github.com/madyankin/postcss-modules/pull/134
|
|
7
42
|
|
|
8
43
|
## 4.3.1
|
|
9
44
|
|
|
10
|
-
-
|
|
45
|
+
- Fixed errors when using shorthand selectors by Felix Bruns (@fxb) https://github.com/madyankin/postcss-modules/pull/130
|
|
11
46
|
|
|
12
47
|
## 4.3.0
|
|
13
48
|
|
|
14
|
-
-
|
|
49
|
+
- Updated the `generic-names` dependency to reduce packages size by Bogdan Chadkin (@TrySound) https://github.com/madyankin/postcss-modules/pull/129
|
|
15
50
|
|
|
16
51
|
## 4.2.2
|
|
17
52
|
|
|
18
|
-
-
|
|
53
|
+
- Fix the build
|
|
19
54
|
|
|
20
55
|
## 4.2.1
|
|
21
56
|
|
|
22
|
-
-
|
|
57
|
+
- Fixed the `resolve` option behaviour by @kamilic https://github.com/madyankin/postcss-modules/pull/127
|
|
23
58
|
|
|
24
59
|
## 4.2.0
|
|
25
60
|
|
|
26
|
-
-
|
|
61
|
+
- Added the `resolve` option to configure lookup paths for composes/from by @kamilic https://github.com/madyankin/postcss-modules/pull/126
|
|
27
62
|
|
|
28
63
|
## 4.1.3
|
|
29
64
|
|
|
30
|
-
-
|
|
65
|
+
- Fixed package contents
|
|
31
66
|
|
|
32
67
|
## 4.1.1
|
|
33
68
|
|
|
34
|
-
-
|
|
69
|
+
- Fixed TypeScript typings by Shuman Lim (@origin-master) https://github.com/madyankin/postcss-modules/pull/124
|
|
35
70
|
|
|
36
71
|
## 4.1.0
|
|
37
72
|
|
|
38
|
-
-
|
|
73
|
+
- Added TypeScript typings by Shuman Lim (@origin-master) https://github.com/madyankin/postcss-modules/pull/123
|
|
39
74
|
|
|
40
75
|
## 4.0.0
|
|
41
76
|
|
|
42
|
-
-
|
|
77
|
+
- Upgraded to PostCSS 8 by Evan You (@yyx990803) https://github.com/css-modules/postcss-modules/pull/114
|
|
43
78
|
|
|
44
79
|
## 3.2.2
|
|
45
80
|
|
|
46
81
|
### Fixed
|
|
47
82
|
|
|
48
|
-
-
|
|
83
|
+
- Fixed user plugins order by Tom Jenkinson (@tjenkinson) https://github.com/css-modules/postcss-modules/pull/112
|
|
49
84
|
|
|
50
85
|
## 3.2.1
|
|
51
86
|
|
|
52
87
|
### Fixed
|
|
53
88
|
|
|
54
|
-
-
|
|
89
|
+
- Fixed an issue when some plugins were running multiple times by Tom Jenkinson (@tjenkinson) https://github.com/css-modules/postcss-modules/pull/111
|
|
55
90
|
|
|
56
91
|
## 3.2.0
|
|
57
92
|
|
|
58
93
|
### Changed
|
|
59
94
|
|
|
60
|
-
-
|
|
95
|
+
- [`localsConvention` option] now supports a custom function `(originalClassName: string, generatedClassName: string, inputFile: string) => className: string` by Gregory Waxman (@Akkuma) https://github.com/css-modules/postcss-modules/pull/109
|
|
61
96
|
|
|
62
97
|
## 3.1.0
|
|
63
98
|
|
|
64
99
|
### Added
|
|
65
100
|
|
|
66
|
-
-
|
|
101
|
+
- Added `exportGlobals` option
|
|
67
102
|
|
|
68
103
|
## 3.0.0
|
|
69
104
|
|
|
70
105
|
### Changed
|
|
71
106
|
|
|
72
|
-
-
|
|
73
|
-
-
|
|
107
|
+
- Dropped `css-modules-loader-core` dependency
|
|
108
|
+
- [Upgraded all the dependencies](https://github.com/css-modules/postcss-modules/pull/108)
|
|
74
109
|
|
|
75
110
|
### Breaking changes
|
|
76
111
|
|
|
77
|
-
-
|
|
112
|
+
- Dropped support for unsupported Node versions. Supported versions are 10, 12 and 14+ https://nodejs.org/en/about/releases/
|
|
78
113
|
|
|
79
114
|
## 2.0.0
|
|
80
115
|
|
|
81
116
|
### Added
|
|
82
117
|
|
|
83
|
-
-
|
|
118
|
+
- [`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>
|
|
84
119
|
|
|
85
120
|
### Breaking changes
|
|
86
121
|
|
|
87
|
-
-
|
|
122
|
+
- `camelCase` camelCase removed, use the [`localsConvention` option](https://github.com/css-modules/postcss-modules#localsconvention) instead.
|
|
88
123
|
|
|
89
124
|
## 1.5.0
|
|
90
125
|
|
|
91
|
-
-
|
|
126
|
+
- Added `hashPrefix` option by Jesse Thomson (@jessethomson) <https://github.com/css-modules/postcss-modules/pull/98>
|
|
92
127
|
|
|
93
128
|
## 1.4.1
|
|
94
129
|
|
|
95
|
-
-
|
|
130
|
+
- Rebublished the previous release. Sorry :(
|
|
96
131
|
|
|
97
132
|
## 1.4.0
|
|
98
133
|
|
|
99
|
-
-
|
|
134
|
+
- Added export for other plugins by Evilebot Tnawi (@evilebottnawi) <https://github.com/css-modules/postcss-modules/pull/88>, <https://github.com/css-modules/postcss-modules/issues/29>
|
|
100
135
|
|
|
101
136
|
## 1.3.1
|
|
102
137
|
|
|
103
|
-
-
|
|
138
|
+
- Move dev tools to devDependecies by Anton Khlynovskiy (@ubzey) <https://github.com/css-modules/postcss-modules/pull/85>
|
|
104
139
|
|
|
105
140
|
## 1.3.0
|
|
106
141
|
|
|
107
|
-
-
|
|
108
|
-
-
|
|
142
|
+
- Updated dependecies
|
|
143
|
+
- Added prettier to format code
|
|
109
144
|
|
|
110
145
|
## 1.2.0
|
|
111
146
|
|
|
112
|
-
-
|
|
147
|
+
- Added option to transform classes to camelCase by Igor Ribeiro (@igor-ribeiro) <https://github.com/css-modules/postcss-modules/pull/82>
|
|
113
148
|
|
|
114
149
|
## 1.1.0
|
|
115
150
|
|
|
116
|
-
-
|
|
151
|
+
- Added ability to transmit outputFileName into getJSON by @lutien <https://github.com/css-modules/postcss-modules/pull/72>
|
|
117
152
|
|
|
118
153
|
## 1.0.0
|
|
119
154
|
|
|
120
|
-
-
|
|
121
|
-
-
|
|
155
|
+
- Dropped support for Node < 6
|
|
156
|
+
- Updated dependencies
|
|
122
157
|
|
|
123
158
|
## 0.8.0
|
|
124
159
|
|
|
125
|
-
-
|
|
160
|
+
- Updated PostCSS to 6 by Alexey Litvinov (@sullenor) <https://github.com/css-modules/postcss-modules/pull/65>
|
|
126
161
|
|
|
127
162
|
## 0.7.1
|
|
128
163
|
|
|
129
|
-
-
|
|
164
|
+
- Allowed empty string as opts.root by Sharon Rolel (@Mosho1) <https://github.com/css-modules/postcss-modules/pull/56>
|
|
130
165
|
|
|
131
166
|
## 0.7.0
|
|
132
167
|
|
|
133
|
-
-
|
|
168
|
+
- Allow async getJSON by Philipp A. (@flying-sheep) <https://github.com/css-modules/postcss-modules/pull/59>
|
|
134
169
|
|
|
135
170
|
## 0.6.4
|
|
136
171
|
|
|
137
|
-
-
|
|
172
|
+
- Added the `root` option to pass the root path by Sharon Rolel (@Mosho1) (<https://github.com/css-modules/postcss-modules/pull/55>)
|
|
138
173
|
|
|
139
174
|
## 0.6.3
|
|
140
175
|
|
|
141
|
-
-
|
|
176
|
+
- Fixed regression in `isValidBehaviour` function (<https://github.com/css-modules/postcss-modules/issues/53>)
|
|
142
177
|
|
|
143
178
|
## 0.6.2
|
|
144
179
|
|
|
145
|
-
-
|
|
180
|
+
- Refactored `getDefaultPluginsList` function
|
|
146
181
|
|
|
147
182
|
## 0.6.1
|
|
148
183
|
|
|
149
|
-
-
|
|
184
|
+
- Fixed `generateScopedName` bug with multiple postcss-modules instances (<https://github.com/css-modules/postcss-modules/issues/37>)
|
|
150
185
|
|
|
151
186
|
## 0.6.0
|
|
152
187
|
|
|
153
|
-
-
|
|
154
|
-
-
|
|
188
|
+
- Added `globalModulePaths` option (Thanks to @pospi).
|
|
189
|
+
- Refactored all the things.
|
|
155
190
|
|
|
156
191
|
## 0.5.2
|
|
157
192
|
|
|
158
|
-
-
|
|
193
|
+
- Updated dependencies
|
|
159
194
|
|
|
160
195
|
## 0.5.1
|
|
161
196
|
|
|
162
|
-
-
|
|
197
|
+
- Fixed sorting for composed dependencies by Josh Johnston (@joshwnj) (<https://github.com/css-modules/postcss-modules/issues/38>)
|
|
163
198
|
|
|
164
199
|
## 0.5.0
|
|
165
200
|
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
201
|
+
- Added `scopeBehaviour` option (<https://github.com/css-modules/postcss-modules/issues/22>)
|
|
202
|
+
- Added ability to pass a string to `generateScopedName` (<https://github.com/css-modules/postcss-modules/issues/21>)
|
|
203
|
+
- Updated dependencies
|
|
169
204
|
|
|
170
205
|
## 0.4.1
|
|
171
206
|
|
|
172
|
-
-
|
|
207
|
+
- Fixed processing errors capturing by Boris Serdiuk (@just-boris)
|
|
173
208
|
|
|
174
209
|
## 0.4.0
|
|
175
210
|
|
|
176
|
-
-
|
|
211
|
+
- Added support for custom loaders by Björn Brauer (@ZauberNerd)
|
|
177
212
|
|
|
178
213
|
## 0.3.0
|
|
179
214
|
|
|
180
|
-
-
|
|
181
|
-
-
|
|
215
|
+
- Fixed processing for imported CSS
|
|
216
|
+
- Added default callback for saving exported JSON
|
|
182
217
|
|
|
183
218
|
## 0.2.0
|
|
184
219
|
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
220
|
+
- Fixed JSON export with shallow imports (<https://github.com/outpunk/postcss-modules/issues/12>)
|
|
221
|
+
- Fixed lookup paths (<https://github.com/outpunk/postcss-modules/issues/13>)
|
|
222
|
+
- Fixed imports overriding (<https://github.com/outpunk/postcss-modules/issues/15>)
|
|
223
|
+
- Global refactoring under the hood
|
|
189
224
|
|
|
190
225
|
## 0.1.3
|
|
191
226
|
|
package/README.md
CHANGED
|
@@ -12,26 +12,26 @@ For example, you have the following CSS:
|
|
|
12
12
|
```css
|
|
13
13
|
/* styles.css */
|
|
14
14
|
:global .page {
|
|
15
|
-
|
|
15
|
+
padding: 20px;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.title {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
composes: title from "./mixins.css";
|
|
20
|
+
color: green;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
.article {
|
|
24
|
-
|
|
24
|
+
font-size: 16px;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/* mixins.css */
|
|
28
28
|
.title {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
color: black;
|
|
30
|
+
font-size: 40px;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.title:hover {
|
|
34
|
-
|
|
34
|
+
color: red;
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -39,24 +39,24 @@ After the transformation it will become like this:
|
|
|
39
39
|
|
|
40
40
|
```css
|
|
41
41
|
._title_116zl_1 {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
color: black;
|
|
43
|
+
font-size: 40px;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
._title_116zl_1:hover {
|
|
47
|
-
|
|
47
|
+
color: red;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.page {
|
|
51
|
-
|
|
51
|
+
padding: 20px;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
._title_xkpkl_5 {
|
|
55
|
-
|
|
55
|
+
color: green;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
._article_xkpkl_10 {
|
|
59
|
-
|
|
59
|
+
font-size: 16px;
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
@@ -64,8 +64,8 @@ And the plugin will give you a JSON object for transformed classes:
|
|
|
64
64
|
|
|
65
65
|
```json
|
|
66
66
|
{
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
"title": "_title_xkpkl_5 _title_116zl_1",
|
|
68
|
+
"article": "_article_xkpkl_10"
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
@@ -79,14 +79,14 @@ use the `getJSON` callback. For example, save data about classes into a correspo
|
|
|
79
79
|
|
|
80
80
|
```js
|
|
81
81
|
postcss([
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
require("postcss-modules")({
|
|
83
|
+
getJSON: function (cssFileName, json, outputFileName) {
|
|
84
|
+
var path = require("path");
|
|
85
|
+
var cssName = path.basename(cssFileName, ".css");
|
|
86
|
+
var jsonFileName = path.resolve("./build/" + cssName + ".json");
|
|
87
|
+
fs.writeFileSync(jsonFileName, JSON.stringify(json));
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
90
|
]);
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -99,9 +99,9 @@ this behaviour using the `scopeBehaviour` option:
|
|
|
99
99
|
|
|
100
100
|
```js
|
|
101
101
|
postcss([
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
require("postcss-modules")({
|
|
103
|
+
scopeBehaviour: "global", // can be 'global' or 'local',
|
|
104
|
+
}),
|
|
105
105
|
]);
|
|
106
106
|
```
|
|
107
107
|
|
|
@@ -120,16 +120,16 @@ To generate custom classes, use the `generateScopedName` callback:
|
|
|
120
120
|
|
|
121
121
|
```js
|
|
122
122
|
postcss([
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
require("postcss-modules")({
|
|
124
|
+
generateScopedName: function (name, filename, css) {
|
|
125
|
+
var path = require("path");
|
|
126
|
+
var i = css.indexOf("." + name);
|
|
127
|
+
var line = css.substr(0, i).split(/[\r\n]/).length;
|
|
128
|
+
var file = path.basename(filename, ".css");
|
|
129
|
+
|
|
130
|
+
return "_" + file + "_" + line + "_" + name;
|
|
131
|
+
},
|
|
132
|
+
}),
|
|
133
133
|
]);
|
|
134
134
|
```
|
|
135
135
|
|
|
@@ -138,9 +138,9 @@ Or just pass an interpolated string to the `generateScopedName` option
|
|
|
138
138
|
|
|
139
139
|
```js
|
|
140
140
|
postcss([
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
require("postcss-modules")({
|
|
142
|
+
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
|
143
|
+
}),
|
|
144
144
|
]);
|
|
145
145
|
```
|
|
146
146
|
|
|
@@ -148,10 +148,10 @@ It's possible to add custom hash to generate more unique classes using the `hash
|
|
|
148
148
|
|
|
149
149
|
```js
|
|
150
150
|
postcss([
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
require("postcss-modules")({
|
|
152
|
+
generateScopedName: "[name]__[local]___[hash:base64:5]",
|
|
153
|
+
hashPrefix: "prefix",
|
|
154
|
+
}),
|
|
155
155
|
]);
|
|
156
156
|
```
|
|
157
157
|
|
|
@@ -161,9 +161,9 @@ If you need to export global names via the JSON object along with the local ones
|
|
|
161
161
|
|
|
162
162
|
```js
|
|
163
163
|
postcss([
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
require("postcss-modules")({
|
|
165
|
+
exportGlobals: true,
|
|
166
|
+
}),
|
|
167
167
|
]);
|
|
168
168
|
```
|
|
169
169
|
|
|
@@ -173,9 +173,9 @@ If you need, you can pass a custom loader (see [FileSystemLoader] for example):
|
|
|
173
173
|
|
|
174
174
|
```js
|
|
175
175
|
postcss([
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
require("postcss-modules")({
|
|
177
|
+
Loader: CustomLoader,
|
|
178
|
+
}),
|
|
179
179
|
]);
|
|
180
180
|
```
|
|
181
181
|
|
|
@@ -207,22 +207,29 @@ In lieu of a string, a custom function can generate the exported class names.
|
|
|
207
207
|
|
|
208
208
|
### Resolve path alias
|
|
209
209
|
|
|
210
|
-
You can rewrite paths for `composes/from` by using `resolve`
|
|
210
|
+
You can rewrite paths for `composes/from` by using the `resolve` option.
|
|
211
211
|
It's useful when you need to resolve custom path alias.
|
|
212
212
|
|
|
213
|
+
Parameters:
|
|
214
|
+
|
|
215
|
+
- `file` — a module we want to resolve
|
|
216
|
+
- `importer` — the file that imports the module we want to resolve
|
|
217
|
+
|
|
218
|
+
Return value: `string | null | Promise<string | null>`
|
|
219
|
+
|
|
213
220
|
```js
|
|
214
221
|
postcss([
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
require("postcss-modules")({
|
|
223
|
+
resolve: function (file, importer) {
|
|
224
|
+
return path.resolve(
|
|
225
|
+
path.dirname(importer),
|
|
226
|
+
file.replace(/^@/, process.cwd()
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
220
230
|
]);
|
|
221
231
|
```
|
|
222
232
|
|
|
223
|
-
`resolve` may also return a `Promise<string>`.
|
|
224
|
-
|
|
225
|
-
|
|
226
233
|
## Integration with templates
|
|
227
234
|
|
|
228
235
|
The plugin only transforms CSS classes to CSS modules.
|
|
@@ -233,8 +240,8 @@ Assume you've saved project's CSS modules in `cssModules.json`:
|
|
|
233
240
|
|
|
234
241
|
```json
|
|
235
242
|
{
|
|
236
|
-
|
|
237
|
-
|
|
243
|
+
"title": "_title_xkpkl_5 _title_116zl_1",
|
|
244
|
+
"article": "_article_xkpkl_10"
|
|
238
245
|
}
|
|
239
246
|
```
|
|
240
247
|
|
|
@@ -261,7 +268,7 @@ And you'll get the following HTML:
|
|
|
261
268
|
```html
|
|
262
269
|
<h1 class="_title_xkpkl_5 _title_116zl_1">postcss-modules</h1>
|
|
263
270
|
<article class="_article_xkpkl_10">
|
|
264
|
-
|
|
271
|
+
A PostCSS plugin to use CSS Modules everywhere
|
|
265
272
|
</article>
|
|
266
273
|
```
|
|
267
274
|
|
|
@@ -278,7 +285,7 @@ Here is our template `about.html`:
|
|
|
278
285
|
```html
|
|
279
286
|
<h1 css-module="title">postcss-modules</h1>
|
|
280
287
|
<article css-module="article">
|
|
281
|
-
|
|
288
|
+
A PostCSS plugin to use CSS Modules everywhere
|
|
282
289
|
</article>
|
|
283
290
|
```
|
|
284
291
|
|
|
@@ -291,20 +298,20 @@ var posthtmlCssModules = require("posthtml-css-modules");
|
|
|
291
298
|
var template = fs.readFileSync("./about.html", "utf8");
|
|
292
299
|
|
|
293
300
|
posthtml([posthtmlCssModules("./cssModules.json")])
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
301
|
+
.process(template)
|
|
302
|
+
.then(function (result) {
|
|
303
|
+
console.log(result.html);
|
|
304
|
+
});
|
|
298
305
|
```
|
|
299
306
|
|
|
300
|
-
(for using other build systems please check [the documentation of PostHTML](https://github.com/posthtml/posthtml/blob/master/
|
|
307
|
+
(for using other build systems please check [the documentation of PostHTML](https://github.com/posthtml/posthtml/blob/master/readme.md))
|
|
301
308
|
|
|
302
309
|
And you'll get the following HTML:
|
|
303
310
|
|
|
304
311
|
```html
|
|
305
312
|
<h1 class="_title_xkpkl_5 _title_116zl_1">postcss-modules</h1>
|
|
306
313
|
<article class="_article_xkpkl_10">
|
|
307
|
-
|
|
314
|
+
A PostCSS plugin to use CSS Modules everywhere
|
|
308
315
|
</article>
|
|
309
316
|
```
|
|
310
317
|
|
|
@@ -320,6 +327,6 @@ npm install --save-dev postcss postcss-modules
|
|
|
320
327
|
|
|
321
328
|
[filesystemloader]: https://github.com/css-modules/css-modules-loader-core/blob/master/src/file-system-loader.js
|
|
322
329
|
|
|
323
|
-
|
|
324
330
|
## Sponsors
|
|
325
|
-
|
|
331
|
+
|
|
332
|
+
- Dmitry Olyenyov
|