Skip to content

Commit cc83876

Browse files
jonathantnealromainmenke
authored andcommitted
2.0.0
1 parent 8211f66 commit cc83876

17 files changed

+504
-156
lines changed

plugins/postcss-env-function/.appveyor.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

plugins/postcss-env-function/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
node_modules
2-
index.*.js
2+
index.*.*
33
package-lock.json
44
*.log*
55
*.result.css
66
.*
7-
!.appveyor.yml
87
!.editorconfig
98
!.gitignore
109
!.rollup.js

plugins/postcss-env-function/.rollup.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import babel from 'rollup-plugin-babel';
33
export default {
44
input: 'index.js',
55
output: [
6-
{ file: 'index.cjs.js', format: 'cjs' },
7-
{ file: 'index.es.js', format: 'es' }
6+
{ file: 'index.cjs.js', format: 'cjs', sourcemap: true },
7+
{ file: 'index.es.mjs', format: 'es', sourcemap: true }
88
],
99
plugins: [
1010
babel({
11+
plugins: [
12+
'@babel/plugin-syntax-dynamic-import'
13+
],
1114
presets: [
12-
['env', { modules: false, targets: { node: 4 } }]
15+
['@babel/env', { modules: false, targets: { node: 6 } }]
1316
]
1417
})
1518
]

plugins/postcss-env-function/.tape.js

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,82 @@
11
module.exports = {
22
'postcss-env-function': {
33
'basic': {
4-
message: 'supports basic usage',
4+
message: 'supports basic usage'
5+
},
6+
'basic:import': {
7+
message: 'supports { importFrom: { environmentVariables: { ... } } } usage',
58
options: {
6-
variables: {
7-
'--some-custom-padding': '20px',
8-
'--another-custom-width': '600px'
9+
importFrom: {
10+
environmentVariables: {
11+
'--some-custom-padding': '20px',
12+
'--another-custom-width': '600px'
13+
}
914
}
1015
}
16+
},
17+
'basic:import-fn': {
18+
message: 'supports { importFrom() } usage',
19+
options: {
20+
importFrom() {
21+
return {
22+
environmentVariables: {
23+
'--some-custom-padding': '20px',
24+
'--another-custom-width': '600px'
25+
}
26+
};
27+
}
28+
},
29+
expect: 'basic.import.expect.css',
30+
result: 'basic.import.result.css'
31+
},
32+
'basic:import-fn-promise': {
33+
message: 'supports { async importFrom() } usage',
34+
options: {
35+
importFrom() {
36+
return new Promise(resolve => {
37+
resolve({
38+
environmentVariables: {
39+
'--some-custom-padding': '20px',
40+
'--another-custom-width': '600px'
41+
}
42+
})
43+
});
44+
}
45+
},
46+
expect: 'basic.import.expect.css',
47+
result: 'basic.import.result.css'
48+
},
49+
'basic:import-json': {
50+
message: 'supports { importFrom: "test/import-variables.json" } usage',
51+
options: {
52+
importFrom: 'test/import-variables.json'
53+
},
54+
expect: 'basic.import.expect.css',
55+
result: 'basic.import.result.css'
56+
},
57+
'basic:import-js': {
58+
message: 'supports { importFrom: "test/import-variables.js" } usage',
59+
options: {
60+
importFrom: 'test/import-variables.js'
61+
},
62+
expect: 'basic.import.expect.css',
63+
result: 'basic.import.result.css'
64+
},
65+
'basic:import-js-from': {
66+
message: 'supports { importFrom: { from: "test/import-variables.js" } } usage',
67+
options: {
68+
importFrom: { from: 'test/import-variables.js' }
69+
},
70+
expect: 'basic.import.expect.css',
71+
result: 'basic.import.result.css'
72+
},
73+
'basic:import-js-from-type': {
74+
message: 'supports { importFrom: [ { from: "test/import-variables.js", type: "js" } ] } usage',
75+
options: {
76+
importFrom: [ { from: 'test/import-variables.js', type: 'js' } ]
77+
},
78+
expect: 'basic.import.expect.css',
79+
result: 'basic.import.result.css'
1180
}
1281
}
1382
};

plugins/postcss-env-function/.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
language: node_js
44

55
node_js:
6-
- 4
6+
- 6
77

88
install:
99
- npm install --ignore-scripts
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes to PostCSS Environment Variables
22

3+
### 2.0.0 (September 17, 2018)
4+
5+
- Updated: Support for PostCSS v7+
6+
- Updated: Support for Node v6+
7+
- Updated: Changed `variables` option to `importFrom` option
8+
39
### 1.0.0 (April 28, 2018)
410

511
- Initial version
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Installing PostCSS Environment Variables
2+
3+
[PostCSS Environment Variables] runs in all Node environments, with special instructions for:
4+
5+
| [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) |
6+
| --- | --- | --- | --- | --- | --- |
7+
8+
## Node
9+
10+
Add [PostCSS Environment Variables] to your project:
11+
12+
```bash
13+
npm install postcss-env-function --save-dev
14+
```
15+
16+
Use [PostCSS Environment Variables] to process your CSS:
17+
18+
```js
19+
const postcssEnvFunction = require('postcss-env-function');
20+
21+
postcssEnvFunction.process(YOUR_CSS /*, processOptions, pluginOptions */);
22+
```
23+
24+
Or use it as a [PostCSS] plugin:
25+
26+
```js
27+
const postcss = require('postcss');
28+
const postcssEnvFunction = require('postcss-env-function');
29+
30+
postcss([
31+
postcssEnvFunction(/* pluginOptions */)
32+
]).process(YOUR_CSS /*, processOptions */);
33+
```
34+
35+
## PostCSS CLI
36+
37+
Add [PostCSS CLI] to your project:
38+
39+
```bash
40+
npm install postcss-cli --save-dev
41+
```
42+
43+
Use [PostCSS Environment Variables] in your `postcss.config.js` configuration file:
44+
45+
```js
46+
const postcssEnvFunction = require('postcss-env-function');
47+
48+
module.exports = {
49+
plugins: [
50+
postcssEnvFunction(/* pluginOptions */)
51+
]
52+
}
53+
```
54+
55+
## Webpack
56+
57+
Add [PostCSS Loader] to your project:
58+
59+
```bash
60+
npm install postcss-loader --save-dev
61+
```
62+
63+
Use [PostCSS Environment Variables] in your Webpack configuration:
64+
65+
```js
66+
const postcssEnvFunction = require('postcss-env-function');
67+
68+
module.exports = {
69+
module: {
70+
rules: [
71+
{
72+
test: /\.css$/,
73+
use: [
74+
'style-loader',
75+
{ loader: 'css-loader', options: { importLoaders: 1 } },
76+
{ loader: 'postcss-loader', options: {
77+
ident: 'postcss',
78+
plugins: () => [
79+
postcssEnvFunction(/* pluginOptions */)
80+
]
81+
} }
82+
]
83+
}
84+
]
85+
}
86+
}
87+
```
88+
89+
## Create React App
90+
91+
Add [React App Rewired] and [React App Rewire PostCSS] to your project:
92+
93+
```bash
94+
npm install react-app-rewired react-app-rewire-postcss --save-dev
95+
```
96+
97+
Use [React App Rewire PostCSS] and [PostCSS Environment Variables] in your
98+
`config-overrides.js` file:
99+
100+
```js
101+
const reactAppRewirePostcss = require('react-app-rewire-postcss');
102+
const postcssEnvFunction = require('postcss-env-function');
103+
104+
module.exports = config => reactAppRewirePostcss(config, {
105+
plugins: () => [
106+
postcssEnvFunction(/* pluginOptions */)
107+
]
108+
});
109+
```
110+
111+
## Gulp
112+
113+
Add [Gulp PostCSS] to your project:
114+
115+
```bash
116+
npm install gulp-postcss --save-dev
117+
```
118+
119+
Use [PostCSS Environment Variables] in your Gulpfile:
120+
121+
```js
122+
const postcss = require('gulp-postcss');
123+
const postcssEnvFunction = require('postcss-env-function');
124+
125+
gulp.task('css', () => gulp.src('./src/*.css').pipe(
126+
postcss([
127+
postcssEnvFunction(/* pluginOptions */)
128+
])
129+
).pipe(
130+
gulp.dest('.')
131+
));
132+
```
133+
134+
## Grunt
135+
136+
Add [Grunt PostCSS] to your project:
137+
138+
```bash
139+
npm install grunt-postcss --save-dev
140+
```
141+
142+
Use [PostCSS Environment Variables] in your Gruntfile:
143+
144+
```js
145+
const postcssEnvFunction = require('postcss-env-function');
146+
147+
grunt.loadNpmTasks('grunt-postcss');
148+
149+
grunt.initConfig({
150+
postcss: {
151+
options: {
152+
use: [
153+
postcssEnvFunction(/* pluginOptions */)
154+
]
155+
},
156+
dist: {
157+
src: '*.css'
158+
}
159+
}
160+
});
161+
```
162+
163+
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
164+
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
165+
[PostCSS]: https://github.com/postcss/postcss
166+
[PostCSS CLI]: https://github.com/postcss/postcss-cli
167+
[PostCSS Loader]: https://github.com/postcss/postcss-loader
168+
[PostCSS Environment Variables]: https://github.com/jonathantneal/postcss-env-function
169+
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
170+
[React App Rewired]: https://github.com/timarney/react-app-rewired

0 commit comments

Comments
 (0)