Skip to content

Commit 6a1a6fc

Browse files
committed
3.0.0
1 parent 6ce644f commit 6a1a6fc

19 files changed

+734
-135
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules
2-
index.*.js
2+
index.*.*
33
package-lock.json
44
*.log*
55
*.result.css

.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
]

.tape.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,57 @@ module.exports = {
2929
'hex': {
3030
message: 'supports hex usage'
3131
},
32+
'import': {
33+
message: 'supports { importFrom: "test/import-root.css" } usage',
34+
options: {
35+
importFrom: 'test/import-root.css'
36+
}
37+
},
38+
'import:array': {
39+
message: 'supports { importFrom: ["test/import-root.css"] } usage',
40+
options: {
41+
importFrom: ['test/import-root.css']
42+
},
43+
expect: 'import.expect.css',
44+
result: 'import.result.css'
45+
},
46+
'import:array-array': {
47+
message: 'supports { importFrom: [["css", "test/import-root.css" ]] } usage',
48+
options: {
49+
importFrom: [['css', 'test/import-root.css' ]]
50+
},
51+
expect: 'import.expect.css',
52+
result: 'import.result.css'
53+
},
54+
'import:js': {
55+
message: 'supports { importFrom: "test/import-root.js" } usage',
56+
options: {
57+
importFrom: 'test/import-root.js'
58+
},
59+
expect: 'import.expect.css',
60+
result: 'import.result.css'
61+
},
62+
'import:json': {
63+
message: 'supports { importFrom: "test/import-root.json" } usage',
64+
options: {
65+
importFrom: 'test/import-root.json'
66+
},
67+
expect: 'import.expect.css',
68+
result: 'import.result.css'
69+
},
70+
'import:object': {
71+
message: 'supports { importFrom: { customProperties: {} } } usage',
72+
options: {
73+
importFrom: {
74+
customProperties: {
75+
'--color-blue': 'blue',
76+
'--color-red': 'red',
77+
'--color': 'var(--color-blue)'
78+
}
79+
}
80+
},
81+
expect: 'import.expect.css',
82+
result: 'import.result.css'
83+
}
3284
}
3385
};

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changes to PostCSS color-mod() Function
22

3+
### 3.0.0 (August 30, 2018)
4+
5+
- Added `importFrom` option which allows you to import Custom Properties from
6+
CSS, JS, and JSON files, and directly passed objects
7+
- Fixed an issue where multiple variables could not be used in `color-mod()`
8+
- Updated to support Node v6+
9+
310
### 2.4.3 (July 21, 2018)
411

512
- Fixed issue with color-mod not being converted within function

INSTALL.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Installing PostCSS color-mod() Function
2+
3+
[PostCSS color-mod() Function] 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 color-mod() Function] to your project:
11+
12+
```bash
13+
npm install postcss-color-mod-function --save-dev
14+
```
15+
16+
Use [PostCSS color-mod() Function] to process your CSS:
17+
18+
```js
19+
const postcssColorMod = require('postcss-color-mod-function');
20+
21+
postcssColorMod.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 postcssColorMod = require('postcss-color-mod-function');
29+
30+
postcss([
31+
postcssColorMod(/* 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 color-mod() Function] in your `postcss.config.js` configuration file:
44+
45+
```js
46+
const postcssColorMod = require('postcss-color-mod-function');
47+
48+
module.exports = {
49+
plugins: [
50+
postcssColorMod(/* 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 color-mod() Function] in your Webpack configuration:
64+
65+
```js
66+
const postcssColorMod = require('postcss-color-mod-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+
postcssColorMod(/* 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 color-mod() Function] in your
98+
`config-overrides.js` file:
99+
100+
```js
101+
const reactAppRewirePostcss = require('react-app-rewire-postcss');
102+
const postcssColorMod = require('postcss-color-mod-function');
103+
104+
module.exports = config => reactAppRewirePostcss(config, {
105+
plugins: () => [
106+
postcssColorMod(/* 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 color-mod() Function] in your Gulpfile:
120+
121+
```js
122+
const postcss = require('gulp-postcss');
123+
const postcssColorMod = require('postcss-color-mod-function');
124+
125+
gulp.task('css', () => gulp.src('./src/*.css').pipe(
126+
postcss([
127+
postcssColorMod(/* 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 color-mod() Function] in your Gruntfile:
143+
144+
```js
145+
const postcssColorMod = require('postcss-color-mod-function');
146+
147+
grunt.loadNpmTasks('grunt-postcss');
148+
149+
grunt.initConfig({
150+
postcss: {
151+
options: {
152+
use: [
153+
postcssColorMod(/* 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 color-mod() Function]: https://github.com/jonathantneal/postcss-color-mod-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)