postcss 8.3.8 → 8.4.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.
Potentially problematic release.
This version of postcss might be problematic. Click here for more details.
- package/README.md +2 -490
- package/lib/container.d.ts +2 -2
- package/lib/container.js +3 -2
- package/lib/css-syntax-error.d.ts +55 -8
- package/lib/css-syntax-error.js +12 -4
- package/lib/input.d.ts +26 -6
- package/lib/input.js +43 -11
- package/lib/lazy-result.d.ts +11 -10
- package/lib/lazy-result.js +4 -2
- package/lib/map-generator.js +48 -11
- package/lib/no-work-result.d.ts +37 -0
- package/lib/no-work-result.js +131 -0
- package/lib/node.d.ts +36 -2
- package/lib/node.js +63 -4
- package/lib/parser.js +25 -5
- package/lib/postcss.d.ts +31 -30
- package/lib/postcss.js +5 -1
- package/lib/postcss.mjs +1 -0
- package/lib/previous-map.js +11 -14
- package/lib/processor.d.ts +5 -4
- package/lib/processor.js +6 -13
- package/lib/result.d.ts +3 -2
- package/lib/stringifier.d.ts +36 -0
- package/lib/stringifier.js +3 -1
- package/lib/terminal-highlight.js +16 -16
- package/lib/warn-once.js +1 -0
- package/lib/warning.d.ts +37 -3
- package/lib/warning.js +5 -3
- package/package.json +5 -4
package/README.md
CHANGED
@@ -40,493 +40,5 @@ at <postcss@evilmartians.com>.
|
|
40
40
|
</a>
|
41
41
|
|
42
42
|
|
43
|
-
##
|
44
|
-
|
45
|
-
PostCSS needs your support. We are accepting donations
|
46
|
-
[at Open Collective](https://opencollective.com/postcss/).
|
47
|
-
|
48
|
-
<a href="https://tailwindcss.com/">
|
49
|
-
<img src="https://refactoringui.nyc3.cdn.digitaloceanspaces.com/tailwind-logo.svg"
|
50
|
-
alt="Sponsored by Tailwind CSS" width="213" height="50">
|
51
|
-
</a> <a href="https://themeisle.com/">
|
52
|
-
<img src="https://mllj2j8xvfl0.i.optimole.com/d0cOXWA.3970~373ad/w:auto/h:auto/q:90/https://s30246.pcdn.co/wp-content/uploads/2019/03/logo.png"
|
53
|
-
alt="Sponsored by ThemeIsle" width="171" height="56">
|
54
|
-
</a>
|
55
|
-
|
56
|
-
|
57
|
-
## Plugins
|
58
|
-
|
59
|
-
Currently, PostCSS has more than 200 plugins. You can find all of the plugins
|
60
|
-
in the [plugins list] or in the [searchable catalog]. Below is a list
|
61
|
-
of our favorite plugins — the best demonstrations of what can be built
|
62
|
-
on top of PostCSS.
|
63
|
-
|
64
|
-
If you have any new ideas, [PostCSS plugin development] is really easy.
|
65
|
-
|
66
|
-
[searchable catalog]: https://www.postcss.parts/
|
67
|
-
[plugins list]: https://github.com/postcss/postcss/blob/main/docs/plugins.md
|
68
|
-
|
69
|
-
|
70
|
-
### Solve Global CSS Problem
|
71
|
-
|
72
|
-
* [`postcss-use`] allows you to explicitly set PostCSS plugins within CSS
|
73
|
-
and execute them only for the current file.
|
74
|
-
* [`postcss-modules`] and [`react-css-modules`] automatically isolate
|
75
|
-
selectors within components.
|
76
|
-
* [`postcss-autoreset`] is an alternative to using a global reset
|
77
|
-
that is better for isolatable components.
|
78
|
-
* [`postcss-initial`] adds `all: initial` support, which resets
|
79
|
-
all inherited styles.
|
80
|
-
* [`cq-prolyfill`] adds container query support, allowing styles that respond
|
81
|
-
to the width of the parent.
|
82
|
-
|
83
|
-
|
84
|
-
### Use Future CSS, Today
|
85
|
-
|
86
|
-
* [`autoprefixer`] adds vendor prefixes, using data from Can I Use.
|
87
|
-
* [`postcss-preset-env`] allows you to use future CSS features today.
|
88
|
-
|
89
|
-
|
90
|
-
### Better CSS Readability
|
91
|
-
|
92
|
-
* [`postcss-nested`] unwraps nested rules the way Sass does.
|
93
|
-
* [`postcss-sorting`] sorts the content of rules and at-rules.
|
94
|
-
* [`postcss-utilities`] includes the most commonly used shortcuts and helpers.
|
95
|
-
* [`short`] adds and extends numerous shorthand properties.
|
96
|
-
|
97
|
-
|
98
|
-
### Images and Fonts
|
99
|
-
|
100
|
-
* [`postcss-assets`] inserts image dimensions and inlines files.
|
101
|
-
* [`postcss-sprites`] generates image sprites.
|
102
|
-
* [`font-magician`] generates all the `@font-face` rules needed in CSS.
|
103
|
-
* [`postcss-inline-svg`] allows you to inline SVG and customize its styles.
|
104
|
-
* [`postcss-write-svg`] allows you to write simple SVG directly in your CSS.
|
105
|
-
* [`webp-in-css`] to use WebP image format in CSS background.
|
106
|
-
* [`avif-in-css`] to use AVIF image format in CSS background.
|
107
|
-
|
108
|
-
### Linters
|
109
|
-
|
110
|
-
* [`stylelint`] is a modular stylesheet linter.
|
111
|
-
* [`stylefmt`] is a tool that automatically formats CSS
|
112
|
-
according `stylelint` rules.
|
113
|
-
* [`doiuse`] lints CSS for browser support, using data from Can I Use.
|
114
|
-
* [`colorguard`] helps you maintain a consistent color palette.
|
115
|
-
|
116
|
-
|
117
|
-
### Other
|
118
|
-
|
119
|
-
* [`postcss-rtl`] combines both-directional (left-to-right and right-to-left) styles in one CSS file.
|
120
|
-
* [`cssnano`] is a modular CSS minifier.
|
121
|
-
* [`lost`] is a feature-rich `calc()` grid system.
|
122
|
-
* [`rtlcss`] mirrors styles for right-to-left locales.
|
123
|
-
|
124
|
-
[PostCSS plugin development]: https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md
|
125
|
-
[`postcss-inline-svg`]: https://github.com/TrySound/postcss-inline-svg
|
126
|
-
[`postcss-preset-env`]: https://github.com/jonathantneal/postcss-preset-env
|
127
|
-
[`react-css-modules`]: https://github.com/gajus/react-css-modules
|
128
|
-
[`postcss-autoreset`]: https://github.com/maximkoretskiy/postcss-autoreset
|
129
|
-
[`postcss-write-svg`]: https://github.com/jonathantneal/postcss-write-svg
|
130
|
-
[`postcss-utilities`]: https://github.com/ismamz/postcss-utilities
|
131
|
-
[`postcss-initial`]: https://github.com/maximkoretskiy/postcss-initial
|
132
|
-
[`postcss-sprites`]: https://github.com/2createStudio/postcss-sprites
|
133
|
-
[`postcss-modules`]: https://github.com/outpunk/postcss-modules
|
134
|
-
[`postcss-sorting`]: https://github.com/hudochenkov/postcss-sorting
|
135
|
-
[`postcss-assets`]: https://github.com/assetsjs/postcss-assets
|
136
|
-
[`font-magician`]: https://github.com/jonathantneal/postcss-font-magician
|
137
|
-
[`autoprefixer`]: https://github.com/postcss/autoprefixer
|
138
|
-
[`cq-prolyfill`]: https://github.com/ausi/cq-prolyfill
|
139
|
-
[`postcss-rtl`]: https://github.com/vkalinichev/postcss-rtl
|
140
|
-
[`postcss-use`]: https://github.com/postcss/postcss-use
|
141
|
-
[`css-modules`]: https://github.com/css-modules/css-modules
|
142
|
-
[`webp-in-css`]: https://github.com/ai/webp-in-css
|
143
|
-
[`avif-in-css`]: https://github.com/nucliweb/avif-in-css
|
144
|
-
[`colorguard`]: https://github.com/SlexAxton/css-colorguard
|
145
|
-
[`stylelint`]: https://github.com/stylelint/stylelint
|
146
|
-
[`stylefmt`]: https://github.com/morishitter/stylefmt
|
147
|
-
[`cssnano`]: https://cssnano.co/
|
148
|
-
[`postcss-nested`]: https://github.com/postcss/postcss-nested
|
149
|
-
[`doiuse`]: https://github.com/anandthakker/doiuse
|
150
|
-
[`rtlcss`]: https://github.com/MohammadYounes/rtlcss
|
151
|
-
[`short`]: https://github.com/jonathantneal/postcss-short
|
152
|
-
[`lost`]: https://github.com/peterramsing/lost
|
153
|
-
|
154
|
-
## Syntaxes
|
155
|
-
|
156
|
-
PostCSS can transform styles in any syntax, not just CSS.
|
157
|
-
If there is not yet support for your favorite syntax,
|
158
|
-
you can write a parser and/or stringifier to extend PostCSS.
|
159
|
-
|
160
|
-
* [`sugarss`] is a indent-based syntax like Sass or Stylus.
|
161
|
-
* [`postcss-syntax`] switch syntax automatically by file extensions.
|
162
|
-
* [`postcss-html`] parsing styles in `<style>` tags of HTML-like files.
|
163
|
-
* [`postcss-markdown`] parsing styles in code blocks of Markdown files.
|
164
|
-
* [`postcss-jsx`] parsing CSS in template / object literals of source files.
|
165
|
-
* [`postcss-styled`] parsing CSS in template literals of source files.
|
166
|
-
* [`postcss-scss`] allows you to work with SCSS
|
167
|
-
*(but does not compile SCSS to CSS)*.
|
168
|
-
* [`postcss-sass`] allows you to work with Sass
|
169
|
-
*(but does not compile Sass to CSS)*.
|
170
|
-
* [`postcss-less`] allows you to work with Less
|
171
|
-
*(but does not compile LESS to CSS)*.
|
172
|
-
* [`postcss-less-engine`] allows you to work with Less
|
173
|
-
*(and DOES compile LESS to CSS using true Less.js evaluation)*.
|
174
|
-
* [`postcss-js`] allows you to write styles in JS or transform
|
175
|
-
React Inline Styles, Radium or JSS.
|
176
|
-
* [`postcss-safe-parser`] finds and fixes CSS syntax errors.
|
177
|
-
* [`midas`] converts a CSS string to highlighted HTML.
|
178
|
-
|
179
|
-
[`postcss-less-engine`]: https://github.com/Crunch/postcss-less
|
180
|
-
[`postcss-safe-parser`]: https://github.com/postcss/postcss-safe-parser
|
181
|
-
[`postcss-syntax`]: https://github.com/gucong3000/postcss-syntax
|
182
|
-
[`postcss-html`]: https://github.com/gucong3000/postcss-html
|
183
|
-
[`postcss-markdown`]: https://github.com/gucong3000/postcss-markdown
|
184
|
-
[`postcss-jsx`]: https://github.com/gucong3000/postcss-jsx
|
185
|
-
[`postcss-styled`]: https://github.com/gucong3000/postcss-styled
|
186
|
-
[`postcss-scss`]: https://github.com/postcss/postcss-scss
|
187
|
-
[`postcss-sass`]: https://github.com/AleshaOleg/postcss-sass
|
188
|
-
[`postcss-less`]: https://github.com/webschik/postcss-less
|
189
|
-
[`postcss-js`]: https://github.com/postcss/postcss-js
|
190
|
-
[`sugarss`]: https://github.com/postcss/sugarss
|
191
|
-
[`midas`]: https://github.com/ben-eb/midas
|
192
|
-
|
193
|
-
|
194
|
-
## Articles
|
195
|
-
|
196
|
-
* [Some things you may think about PostCSS… and you might be wrong](http://julian.io/some-things-you-may-think-about-postcss-and-you-might-be-wrong)
|
197
|
-
* [What PostCSS Really Is; What It Really Does](https://davidtheclark.com/its-time-for-everyone-to-learn-about-postcss/)
|
198
|
-
* [PostCSS Guides](https://webdesign.tutsplus.com/series/postcss-deep-dive--cms-889)
|
199
|
-
|
200
|
-
More articles and videos you can find on [awesome-postcss](https://github.com/jjaderg/awesome-postcss) list.
|
201
|
-
|
202
|
-
|
203
|
-
## Books
|
204
|
-
|
205
|
-
* [Mastering PostCSS for Web Design](https://www.packtpub.com/web-development/mastering-postcss-web-design) by Alex Libby, Packt. (June 2016)
|
206
|
-
|
207
|
-
|
208
|
-
## Usage
|
209
|
-
|
210
|
-
You can start using PostCSS in just two steps:
|
211
|
-
|
212
|
-
1. Find and add PostCSS extensions for your build tool.
|
213
|
-
2. [Select plugins] and add them to your PostCSS process.
|
214
|
-
|
215
|
-
[Select plugins]: https://www.postcss.parts/
|
216
|
-
|
217
|
-
|
218
|
-
### CSS-in-JS
|
219
|
-
|
220
|
-
The best way to use PostCSS with CSS-in-JS is [`astroturf`].
|
221
|
-
Add its loader to your `webpack.config.js`:
|
222
|
-
|
223
|
-
```js
|
224
|
-
module.exports = {
|
225
|
-
module: {
|
226
|
-
rules: [
|
227
|
-
{
|
228
|
-
test: /\.css$/,
|
229
|
-
use: ['style-loader', 'postcss-loader'],
|
230
|
-
},
|
231
|
-
{
|
232
|
-
test: /\.jsx?$/,
|
233
|
-
use: ['babel-loader', 'astroturf/loader'],
|
234
|
-
}
|
235
|
-
]
|
236
|
-
}
|
237
|
-
}
|
238
|
-
```
|
239
|
-
|
240
|
-
Then create `postcss.config.js`:
|
241
|
-
|
242
|
-
```js
|
243
|
-
module.exports = {
|
244
|
-
plugins: [
|
245
|
-
require('autoprefixer'),
|
246
|
-
require('postcss-nested')
|
247
|
-
]
|
248
|
-
}
|
249
|
-
```
|
250
|
-
|
251
|
-
[`astroturf`]: https://github.com/4Catalyzer/astroturf
|
252
|
-
|
253
|
-
|
254
|
-
### Parcel
|
255
|
-
|
256
|
-
[Parcel] has built-in PostCSS support. It already uses Autoprefixer
|
257
|
-
and cssnano. If you want to change plugins, create `postcss.config.js`
|
258
|
-
in project’s root:
|
259
|
-
|
260
|
-
```js
|
261
|
-
module.exports = {
|
262
|
-
plugins: [
|
263
|
-
require('autoprefixer'),
|
264
|
-
require('postcss-nested')
|
265
|
-
]
|
266
|
-
}
|
267
|
-
```
|
268
|
-
|
269
|
-
Parcel will even automatically install these plugins for you.
|
270
|
-
|
271
|
-
> Please, be aware of [the several issues in Version 1](https://github.com/parcel-bundler/parcel/labels/CSS%20Preprocessing). Notice, [Version 2](https://github.com/parcel-bundler/parcel/projects/5) may resolve the issues via [issue #2157](https://github.com/parcel-bundler/parcel/issues/2157).
|
272
|
-
|
273
|
-
[Parcel]: https://parceljs.org
|
274
|
-
|
275
|
-
|
276
|
-
### Webpack
|
277
|
-
|
278
|
-
Use [`postcss-loader`] in `webpack.config.js`:
|
279
|
-
|
280
|
-
```js
|
281
|
-
module.exports = {
|
282
|
-
module: {
|
283
|
-
rules: [
|
284
|
-
{
|
285
|
-
test: /\.css$/,
|
286
|
-
exclude: /node_modules/,
|
287
|
-
use: [
|
288
|
-
{
|
289
|
-
loader: 'style-loader',
|
290
|
-
},
|
291
|
-
{
|
292
|
-
loader: 'css-loader',
|
293
|
-
options: {
|
294
|
-
importLoaders: 1,
|
295
|
-
}
|
296
|
-
},
|
297
|
-
{
|
298
|
-
loader: 'postcss-loader'
|
299
|
-
}
|
300
|
-
]
|
301
|
-
}
|
302
|
-
]
|
303
|
-
}
|
304
|
-
}
|
305
|
-
```
|
306
|
-
|
307
|
-
Then create `postcss.config.js`:
|
308
|
-
|
309
|
-
```js
|
310
|
-
module.exports = {
|
311
|
-
plugins: [
|
312
|
-
require('autoprefixer'),
|
313
|
-
require('postcss-nested')
|
314
|
-
]
|
315
|
-
}
|
316
|
-
```
|
317
|
-
|
318
|
-
[`postcss-loader`]: https://github.com/postcss/postcss-loader
|
319
|
-
|
320
|
-
|
321
|
-
### Gulp
|
322
|
-
|
323
|
-
Use [`gulp-postcss`] and [`gulp-sourcemaps`].
|
324
|
-
|
325
|
-
```js
|
326
|
-
gulp.task('css', () => {
|
327
|
-
const postcss = require('gulp-postcss')
|
328
|
-
const sourcemaps = require('gulp-sourcemaps')
|
329
|
-
|
330
|
-
return gulp.src('src/**/*.css')
|
331
|
-
.pipe( sourcemaps.init() )
|
332
|
-
.pipe( postcss([ require('autoprefixer'), require('postcss-nested') ]) )
|
333
|
-
.pipe( sourcemaps.write('.') )
|
334
|
-
.pipe( gulp.dest('build/') )
|
335
|
-
})
|
336
|
-
```
|
337
|
-
|
338
|
-
[`gulp-sourcemaps`]: https://github.com/floridoo/gulp-sourcemaps
|
339
|
-
[`gulp-postcss`]: https://github.com/postcss/gulp-postcss
|
340
|
-
|
341
|
-
|
342
|
-
### npm Scripts
|
343
|
-
|
344
|
-
To use PostCSS from your command-line interface or with npm scripts
|
345
|
-
there is [`postcss-cli`].
|
346
|
-
|
347
|
-
```sh
|
348
|
-
postcss --use autoprefixer -o main.css css/*.css
|
349
|
-
```
|
350
|
-
|
351
|
-
[`postcss-cli`]: https://github.com/postcss/postcss-cli
|
352
|
-
|
353
|
-
|
354
|
-
### Browser
|
355
|
-
|
356
|
-
If you want to compile CSS string in browser (for instance, in live edit
|
357
|
-
tools like CodePen), just use [Browserify] or [webpack]. They will pack
|
358
|
-
PostCSS and plugins files into a single file.
|
359
|
-
|
360
|
-
To apply PostCSS plugins to React Inline Styles, JSS, Radium
|
361
|
-
and other [CSS-in-JS], you can use [`postcss-js`] and transforms style objects.
|
362
|
-
|
363
|
-
```js
|
364
|
-
const postcss = require('postcss-js')
|
365
|
-
const prefixer = postcss.sync([ require('autoprefixer') ])
|
366
|
-
|
367
|
-
prefixer({ display: 'flex' }) //=> { display: ['-webkit-box', '-webkit-flex', '-ms-flexbox', 'flex'] }
|
368
|
-
```
|
369
|
-
|
370
|
-
[`postcss-js`]: https://github.com/postcss/postcss-js
|
371
|
-
[Browserify]: http://browserify.org/
|
372
|
-
[CSS-in-JS]: https://github.com/MicheleBertoli/css-in-js
|
373
|
-
[webpack]: https://webpack.github.io/
|
374
|
-
|
375
|
-
|
376
|
-
### Deno
|
377
|
-
|
378
|
-
PostCSS also supports [Deno]:
|
379
|
-
|
380
|
-
```js
|
381
|
-
import postcss from 'https://deno.land/x/postcss/mod.js'
|
382
|
-
import autoprefixer from 'https://jspm.dev/autoprefixer'
|
383
|
-
|
384
|
-
const result = await postcss([autoprefixer]).process(css)
|
385
|
-
```
|
386
|
-
|
387
|
-
[Deno]: https://deno.land/
|
388
|
-
|
389
|
-
|
390
|
-
### Runners
|
391
|
-
|
392
|
-
* **Grunt**: [`@lodder/grunt-postcss`](https://github.com/C-Lodder/grunt-postcss)
|
393
|
-
* **HTML**: [`posthtml-postcss`](https://github.com/posthtml/posthtml-postcss)
|
394
|
-
* **Stylus**: [`poststylus`](https://github.com/seaneking/poststylus)
|
395
|
-
* **Rollup**: [`rollup-plugin-postcss`](https://github.com/egoist/rollup-plugin-postcss)
|
396
|
-
* **Brunch**: [`postcss-brunch`](https://github.com/brunch/postcss-brunch)
|
397
|
-
* **Broccoli**: [`broccoli-postcss`](https://github.com/jeffjewiss/broccoli-postcss)
|
398
|
-
* **Meteor**: [`postcss`](https://atmospherejs.com/juliancwirko/postcss)
|
399
|
-
* **ENB**: [`enb-postcss`](https://github.com/awinogradov/enb-postcss)
|
400
|
-
* **Taskr**: [`taskr-postcss`](https://github.com/lukeed/taskr/tree/master/packages/postcss)
|
401
|
-
* **Start**: [`start-postcss`](https://github.com/start-runner/postcss)
|
402
|
-
* **Connect/Express**: [`postcss-middleware`](https://github.com/jedmao/postcss-middleware)
|
403
|
-
|
404
|
-
|
405
|
-
### JS API
|
406
|
-
|
407
|
-
For other environments, you can use the JS API:
|
408
|
-
|
409
|
-
```js
|
410
|
-
const autoprefixer = require('autoprefixer')
|
411
|
-
const postcss = require('postcss')
|
412
|
-
const postcssNested = require('postcss-nested')
|
413
|
-
const fs = require('fs')
|
414
|
-
|
415
|
-
fs.readFile('src/app.css', (err, css) => {
|
416
|
-
postcss([autoprefixer, postcssNested])
|
417
|
-
.process(css, { from: 'src/app.css', to: 'dest/app.css' })
|
418
|
-
.then(result => {
|
419
|
-
fs.writeFile('dest/app.css', result.css, () => true)
|
420
|
-
if ( result.map ) {
|
421
|
-
fs.writeFile('dest/app.css.map', result.map.toString(), () => true)
|
422
|
-
}
|
423
|
-
})
|
424
|
-
})
|
425
|
-
```
|
426
|
-
|
427
|
-
Read the [PostCSS API documentation] for more details about the JS API.
|
428
|
-
|
429
|
-
All PostCSS runners should pass [PostCSS Runner Guidelines].
|
430
|
-
|
431
|
-
[PostCSS Runner Guidelines]: https://github.com/postcss/postcss/blob/main/docs/guidelines/runner.md
|
432
|
-
[PostCSS API documentation]: https://postcss.org/api/
|
433
|
-
|
434
|
-
|
435
|
-
### Options
|
436
|
-
|
437
|
-
Most PostCSS runners accept two parameters:
|
438
|
-
|
439
|
-
* An array of plugins.
|
440
|
-
* An object of options.
|
441
|
-
|
442
|
-
Common options:
|
443
|
-
|
444
|
-
* `syntax`: an object providing a syntax parser and a stringifier.
|
445
|
-
* `parser`: a special syntax parser (for example, [SCSS]).
|
446
|
-
* `stringifier`: a special syntax output generator (for example, [Midas]).
|
447
|
-
* `map`: [source map options].
|
448
|
-
* `from`: the input file name (most runners set it automatically).
|
449
|
-
* `to`: the output file name (most runners set it automatically).
|
450
|
-
|
451
|
-
[source map options]: https://postcss.org/api/#sourcemapoptions
|
452
|
-
[Midas]: https://github.com/ben-eb/midas
|
453
|
-
[SCSS]: https://github.com/postcss/postcss-scss
|
454
|
-
|
455
|
-
|
456
|
-
### Treat Warnings as Errors
|
457
|
-
|
458
|
-
In some situations it might be helpful to fail the build on any warning
|
459
|
-
from PostCSS or one of its plugins. This guarantees that no warnings
|
460
|
-
go unnoticed, and helps to avoid bugs. While there is no option to enable
|
461
|
-
treating warnings as errors, it can easily be done
|
462
|
-
by adding `postcss-fail-on-warn` plugin in the end of PostCSS plugins:
|
463
|
-
|
464
|
-
```js
|
465
|
-
module.exports = {
|
466
|
-
plugins: [
|
467
|
-
require('autoprefixer'),
|
468
|
-
require('postcss-fail-on-warn')
|
469
|
-
]
|
470
|
-
}
|
471
|
-
```
|
472
|
-
|
473
|
-
|
474
|
-
## Editors & IDE Integration
|
475
|
-
|
476
|
-
|
477
|
-
### VS Code
|
478
|
-
|
479
|
-
* [`csstools.postcss`] adds support for PostCSS, `postcss-preset-env`
|
480
|
-
and CSS Modules.
|
481
|
-
|
482
|
-
[`csstools.postcss`]: https://marketplace.visualstudio.com/items?itemName=csstools.postcss
|
483
|
-
|
484
|
-
|
485
|
-
### Atom
|
486
|
-
|
487
|
-
* [`language-postcss`] adds PostCSS and [SugarSS] highlight.
|
488
|
-
* [`source-preview-postcss`] previews your output CSS in a separate, live pane.
|
489
|
-
|
490
|
-
[SugarSS]: https://github.com/postcss/sugarss
|
491
|
-
|
492
|
-
|
493
|
-
### Sublime Text
|
494
|
-
|
495
|
-
* [`Syntax-highlighting-for-PostCSS`] adds PostCSS highlight.
|
496
|
-
|
497
|
-
[`Syntax-highlighting-for-PostCSS`]: https://github.com/hudochenkov/Syntax-highlighting-for-PostCSS
|
498
|
-
[`source-preview-postcss`]: https://atom.io/packages/source-preview-postcss
|
499
|
-
[`language-postcss`]: https://atom.io/packages/language-postcss
|
500
|
-
|
501
|
-
|
502
|
-
### Vim
|
503
|
-
|
504
|
-
* [`postcss.vim`] adds PostCSS highlight.
|
505
|
-
|
506
|
-
[`postcss.vim`]: https://github.com/stephenway/postcss.vim
|
507
|
-
|
508
|
-
|
509
|
-
### WebStorm
|
510
|
-
|
511
|
-
WebStorm 2016.3 [has] built-in PostCSS support.
|
512
|
-
|
513
|
-
[has]: https://blog.jetbrains.com/webstorm/2016/08/webstorm-2016-3-early-access-preview/
|
514
|
-
|
515
|
-
|
516
|
-
## Security Contact
|
517
|
-
|
518
|
-
To report a security vulnerability, please use the [Tidelift security contact].
|
519
|
-
Tidelift will coordinate the fix and disclosure.
|
520
|
-
|
521
|
-
[Tidelift security contact]: https://tidelift.com/security
|
522
|
-
|
523
|
-
|
524
|
-
## For Enterprise
|
525
|
-
|
526
|
-
Available as part of the Tidelift Subscription.
|
527
|
-
|
528
|
-
The maintainers of `postcss` and thousands of other packages are working
|
529
|
-
with Tidelift to deliver commercial support and maintenance for the open source
|
530
|
-
dependencies you use to build your applications. Save time, reduce risk,
|
531
|
-
and improve code health, while paying the maintainers of the exact dependencies
|
532
|
-
you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-postcss?utm_source=npm-postcss&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
43
|
+
## Docs
|
44
|
+
Read **[full docs](https://github.com/postcss/postcss#readme)** on GitHub.
|
package/lib/container.d.ts
CHANGED
@@ -181,10 +181,10 @@ export default abstract class Container<
|
|
181
181
|
*/
|
182
182
|
walkRules(
|
183
183
|
selectorFilter: string | RegExp,
|
184
|
-
callback: (
|
184
|
+
callback: (rule: Rule, index: number) => false | void
|
185
185
|
): false | undefined
|
186
186
|
walkRules(
|
187
|
-
callback: (
|
187
|
+
callback: (rule: Rule, index: number) => false | void
|
188
188
|
): false | undefined
|
189
189
|
|
190
190
|
/**
|
package/lib/container.js
CHANGED
@@ -316,7 +316,7 @@ class Container extends Node {
|
|
316
316
|
}
|
317
317
|
|
318
318
|
let processed = nodes.map(i => {
|
319
|
-
|
319
|
+
/* c8 ignore next */
|
320
320
|
if (!i[my]) Container.rebuild(i)
|
321
321
|
i = i.proxyOf
|
322
322
|
if (i.parent) i.parent.removeChild(i)
|
@@ -410,7 +410,7 @@ Container.registerAtRule = dependant => {
|
|
410
410
|
module.exports = Container
|
411
411
|
Container.default = Container
|
412
412
|
|
413
|
-
|
413
|
+
/* c8 ignore start */
|
414
414
|
Container.rebuild = node => {
|
415
415
|
if (node.type === 'atrule') {
|
416
416
|
Object.setPrototypeOf(node, AtRule.prototype)
|
@@ -430,3 +430,4 @@ Container.rebuild = node => {
|
|
430
430
|
})
|
431
431
|
}
|
432
432
|
}
|
433
|
+
/* c8 ignore stop */
|
@@ -1,5 +1,20 @@
|
|
1
1
|
import { FilePosition } from './input.js'
|
2
2
|
|
3
|
+
/**
|
4
|
+
* A position that is part of a range.
|
5
|
+
*/
|
6
|
+
export interface RangePosition {
|
7
|
+
/**
|
8
|
+
* The line number in the input.
|
9
|
+
*/
|
10
|
+
line: number
|
11
|
+
|
12
|
+
/**
|
13
|
+
* The column number in the input.
|
14
|
+
*/
|
15
|
+
column: number
|
16
|
+
}
|
17
|
+
|
3
18
|
/**
|
4
19
|
* The CSS parser throws this error for broken CSS.
|
5
20
|
*
|
@@ -31,17 +46,21 @@ import { FilePosition } from './input.js'
|
|
31
46
|
*/
|
32
47
|
export default class CssSyntaxError {
|
33
48
|
/**
|
34
|
-
*
|
35
|
-
*
|
36
|
-
* @param
|
37
|
-
* @param
|
38
|
-
*
|
39
|
-
* @param
|
49
|
+
* Instantiates a CSS syntax error. Can be instantiated for a single position
|
50
|
+
* or for a range.
|
51
|
+
* @param message Error message.
|
52
|
+
* @param lineOrStartPos If for a single position, the line number, or if for
|
53
|
+
* a range, the inclusive start position of the error.
|
54
|
+
* @param columnOrEndPos If for a single position, the column number, or if for
|
55
|
+
* a range, the exclusive end position of the error.
|
56
|
+
* @param source Source code of the broken file.
|
57
|
+
* @param file Absolute path to the broken file.
|
58
|
+
* @param plugin PostCSS plugin name, if error came from plugin.
|
40
59
|
*/
|
41
60
|
constructor(
|
42
61
|
message: string,
|
43
|
-
|
44
|
-
|
62
|
+
lineOrStartPos?: number | RangePosition,
|
63
|
+
columnOrEndPos?: number | RangePosition,
|
45
64
|
source?: string,
|
46
65
|
file?: string,
|
47
66
|
plugin?: string
|
@@ -121,6 +140,34 @@ export default class CssSyntaxError {
|
|
121
140
|
*/
|
122
141
|
column?: number
|
123
142
|
|
143
|
+
/**
|
144
|
+
* Source line of the error's end, exclusive. Provided if the error pertains
|
145
|
+
* to a range.
|
146
|
+
*
|
147
|
+
* ```js
|
148
|
+
* error.endLine //=> 3
|
149
|
+
* error.input.endLine //=> 4
|
150
|
+
* ```
|
151
|
+
*
|
152
|
+
* PostCSS will use the input source map to detect the original location.
|
153
|
+
* If you need the position in the PostCSS input, use `error.input.endLine`.
|
154
|
+
*/
|
155
|
+
endLine?: number
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Source column of the error's end, exclusive. Provided if the error pertains
|
159
|
+
* to a range.
|
160
|
+
*
|
161
|
+
* ```js
|
162
|
+
* error.endColumn //=> 1
|
163
|
+
* error.input.endColumn //=> 4
|
164
|
+
* ```
|
165
|
+
*
|
166
|
+
* PostCSS will use the input source map to detect the original location.
|
167
|
+
* If you need the position in the PostCSS input, use `error.input.endColumn`.
|
168
|
+
*/
|
169
|
+
endColumn?: number
|
170
|
+
|
124
171
|
/**
|
125
172
|
* Source code of the broken file.
|
126
173
|
*
|
package/lib/css-syntax-error.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
let
|
3
|
+
let pico = require('picocolors')
|
4
4
|
|
5
5
|
let terminalHighlight = require('./terminal-highlight')
|
6
6
|
|
@@ -20,8 +20,15 @@ class CssSyntaxError extends Error {
|
|
20
20
|
this.plugin = plugin
|
21
21
|
}
|
22
22
|
if (typeof line !== 'undefined' && typeof column !== 'undefined') {
|
23
|
-
|
24
|
-
|
23
|
+
if (typeof line === 'number') {
|
24
|
+
this.line = line
|
25
|
+
this.column = column
|
26
|
+
} else {
|
27
|
+
this.line = line.line
|
28
|
+
this.column = line.column
|
29
|
+
this.endLine = column.line
|
30
|
+
this.endColumn = column.column
|
31
|
+
}
|
25
32
|
}
|
26
33
|
|
27
34
|
this.setMessage()
|
@@ -44,7 +51,7 @@ class CssSyntaxError extends Error {
|
|
44
51
|
if (!this.source) return ''
|
45
52
|
|
46
53
|
let css = this.source
|
47
|
-
if (color == null) color = isColorSupported
|
54
|
+
if (color == null) color = pico.isColorSupported
|
48
55
|
if (terminalHighlight) {
|
49
56
|
if (color) css = terminalHighlight(css)
|
50
57
|
}
|
@@ -57,6 +64,7 @@ class CssSyntaxError extends Error {
|
|
57
64
|
|
58
65
|
let mark, aside
|
59
66
|
if (color) {
|
67
|
+
let { bold, red, gray } = pico.createColors(true)
|
60
68
|
mark = text => bold(red(text))
|
61
69
|
aside = text => gray(text)
|
62
70
|
} else {
|