-
-
Notifications
You must be signed in to change notification settings - Fork 75
PostCSS Global Data #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
PostCSS Global Data #841
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
913e920
Creating new Plugin
Antonio-Laguna 2a82ce2
Clarifying doc
Antonio-Laguna c8afac7
Linting
Antonio-Laguna c18aefc
Update plugins/postcss-global-data/src/index.ts
Antonio-Laguna fda6b11
Simpler tests
Antonio-Laguna 7d08907
Update plugins/postcss-global-data/docs/README.md
Antonio-Laguna cfaf944
remove unused examples
Antonio-Laguna e3fb6f7
adding some keywords
Antonio-Laguna 9953040
linting
Antonio-Laguna 25ffaf1
regenerating docs
Antonio-Laguna 46d862b
examples are not mandatory
Antonio-Laguna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
package-lock.json | ||
yarn.lock | ||
*.result.css | ||
*.result.css.map | ||
*.result.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18.8.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { postcssTape } from '../../packages/postcss-tape/dist/index.mjs'; | ||
import plugin from '@csstools/postcss-global-data'; | ||
import postcssCustomMedia from 'postcss-custom-media'; | ||
|
||
postcssTape(plugin)({ | ||
basic: { | ||
message: "supports basic usage", | ||
plugins: [ | ||
plugin({ | ||
files: [ | ||
'./test/fixtures/fixture.css', | ||
] | ||
}), | ||
postcssCustomMedia(), | ||
], | ||
}, | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changes to PostCSS global-data | ||
|
||
### Unreleased (major) | ||
|
||
- Initial version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
# Installing PostCSS Global Data | ||
|
||
[PostCSS Global Data] runs in all Node environments, with special instructions for: | ||
|
||
- [Node](#node) | ||
- [PostCSS CLI](#postcss-cli) | ||
- [PostCSS Load Config](#postcss-load-config) | ||
- [Webpack](#webpack) | ||
- [Next.js](#nextjs) | ||
- [Gulp](#gulp) | ||
- [Grunt](#grunt) | ||
|
||
|
||
|
||
## Node | ||
|
||
Add [PostCSS Global Data] to your project: | ||
|
||
```bash | ||
npm install postcss @csstools/postcss-global-data --save-dev | ||
``` | ||
|
||
Use it as a [PostCSS] plugin: | ||
|
||
```js | ||
// commonjs | ||
const postcss = require('postcss'); | ||
const postcssGlobalData = require('@csstools/postcss-global-data'); | ||
|
||
postcss([ | ||
postcssGlobalData(/* pluginOptions */) | ||
]).process(YOUR_CSS /*, processOptions */); | ||
``` | ||
|
||
```js | ||
// esm | ||
import postcss from 'postcss'; | ||
import postcssGlobalData from '@csstools/postcss-global-data'; | ||
|
||
postcss([ | ||
postcssGlobalData(/* pluginOptions */) | ||
]).process(YOUR_CSS /*, processOptions */); | ||
``` | ||
|
||
## PostCSS CLI | ||
|
||
Add [PostCSS CLI] to your project: | ||
|
||
```bash | ||
npm install postcss-cli @csstools/postcss-global-data --save-dev | ||
``` | ||
|
||
Use [PostCSS Global Data] in your `postcss.config.js` configuration file: | ||
|
||
```js | ||
const postcssGlobalData = require('@csstools/postcss-global-data'); | ||
|
||
module.exports = { | ||
plugins: [ | ||
postcssGlobalData(/* pluginOptions */) | ||
] | ||
} | ||
``` | ||
|
||
## PostCSS Load Config | ||
|
||
If your framework/CLI supports [`postcss-load-config`](https://github.com/postcss/postcss-load-config). | ||
|
||
```bash | ||
npm install @csstools/postcss-global-data --save-dev | ||
``` | ||
|
||
`package.json`: | ||
|
||
```json | ||
{ | ||
"postcss": { | ||
"plugins": { | ||
"@csstools/postcss-global-data": {} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
`.postcssrc.json`: | ||
|
||
```json | ||
{ | ||
"plugins": { | ||
"@csstools/postcss-global-data": {} | ||
} | ||
} | ||
``` | ||
|
||
_See the [README of `postcss-load-config`](https://github.com/postcss/postcss-load-config#usage) for more usage options._ | ||
|
||
## Webpack | ||
|
||
_Webpack version 5_ | ||
|
||
Add [PostCSS Loader] to your project: | ||
|
||
```bash | ||
npm install postcss-loader @csstools/postcss-global-data --save-dev | ||
``` | ||
|
||
Use [PostCSS Global Data] in your Webpack configuration: | ||
|
||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
use: [ | ||
"style-loader", | ||
{ | ||
loader: "css-loader", | ||
options: { importLoaders: 1 }, | ||
}, | ||
{ | ||
loader: "postcss-loader", | ||
options: { | ||
postcssOptions: { | ||
plugins: [ | ||
// Other plugins, | ||
[ | ||
"@csstools/postcss-global-data", | ||
{ | ||
// Options | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
|
||
## Next.js | ||
|
||
Read the instructions on how to [customize the PostCSS configuration in Next.js](https://nextjs.org/docs/advanced-features/customizing-postcss-config) | ||
|
||
```bash | ||
npm install @csstools/postcss-global-data --save-dev | ||
``` | ||
|
||
Use [PostCSS Global Data] in your `postcss.config.json` file: | ||
|
||
```json | ||
{ | ||
"plugins": [ | ||
"@csstools/postcss-global-data" | ||
] | ||
} | ||
``` | ||
|
||
```json5 | ||
{ | ||
"plugins": [ | ||
[ | ||
"@csstools/postcss-global-data", | ||
{ | ||
// Optionally add plugin options | ||
} | ||
] | ||
] | ||
} | ||
``` | ||
|
||
## Gulp | ||
|
||
Add [Gulp PostCSS] to your project: | ||
|
||
```bash | ||
npm install gulp-postcss @csstools/postcss-global-data --save-dev | ||
``` | ||
|
||
Use [PostCSS Global Data] in your Gulpfile: | ||
|
||
```js | ||
const postcss = require('gulp-postcss'); | ||
const postcssGlobalData = require('@csstools/postcss-global-data'); | ||
|
||
gulp.task('css', function () { | ||
var plugins = [ | ||
postcssGlobalData(/* pluginOptions */) | ||
]; | ||
|
||
return gulp.src('./src/*.css') | ||
.pipe(postcss(plugins)) | ||
.pipe(gulp.dest('.')); | ||
}); | ||
``` | ||
|
||
## Grunt | ||
|
||
Add [Grunt PostCSS] to your project: | ||
|
||
```bash | ||
npm install grunt-postcss @csstools/postcss-global-data --save-dev | ||
``` | ||
|
||
Use [PostCSS Global Data] in your Gruntfile: | ||
|
||
```js | ||
const postcssGlobalData = require('@csstools/postcss-global-data'); | ||
|
||
grunt.loadNpmTasks('grunt-postcss'); | ||
|
||
grunt.initConfig({ | ||
postcss: { | ||
options: { | ||
processors: [ | ||
postcssGlobalData(/* pluginOptions */) | ||
] | ||
}, | ||
dist: { | ||
src: '*.css' | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss | ||
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[PostCSS CLI]: https://github.com/postcss/postcss-cli | ||
[PostCSS Loader]: https://github.com/postcss/postcss-loader | ||
[PostCSS Global Data]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-global-data | ||
[Next.js]: https://nextjs.org |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.