Skip to content

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Sep 17, 2018
1 parent 6ce644f commit 6a1a6fc
Show file tree
Hide file tree
Showing 19 changed files with 734 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
index.*.js
index.*.*
package-lock.json
*.log*
*.result.css
Expand Down
9 changes: 6 additions & 3 deletions .rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import babel from 'rollup-plugin-babel';
export default {
input: 'index.js',
output: [
{ file: 'index.cjs.js', format: 'cjs' },
{ file: 'index.es.js', format: 'es' }
{ file: 'index.cjs.js', format: 'cjs', sourcemap: true },
{ file: 'index.es.mjs', format: 'es', sourcemap: true }
],
plugins: [
babel({
plugins: [
'@babel/plugin-syntax-dynamic-import'
],
presets: [
['env', { modules: false, targets: { node: 4 } }]
['@babel/env', { modules: false, targets: { node: 6 } }]
]
})
]
Expand Down
52 changes: 52 additions & 0 deletions .tape.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,57 @@ module.exports = {
'hex': {
message: 'supports hex usage'
},
'import': {
message: 'supports { importFrom: "test/import-root.css" } usage',
options: {
importFrom: 'test/import-root.css'
}
},
'import:array': {
message: 'supports { importFrom: ["test/import-root.css"] } usage',
options: {
importFrom: ['test/import-root.css']
},
expect: 'import.expect.css',
result: 'import.result.css'
},
'import:array-array': {
message: 'supports { importFrom: [["css", "test/import-root.css" ]] } usage',
options: {
importFrom: [['css', 'test/import-root.css' ]]
},
expect: 'import.expect.css',
result: 'import.result.css'
},
'import:js': {
message: 'supports { importFrom: "test/import-root.js" } usage',
options: {
importFrom: 'test/import-root.js'
},
expect: 'import.expect.css',
result: 'import.result.css'
},
'import:json': {
message: 'supports { importFrom: "test/import-root.json" } usage',
options: {
importFrom: 'test/import-root.json'
},
expect: 'import.expect.css',
result: 'import.result.css'
},
'import:object': {
message: 'supports { importFrom: { customProperties: {} } } usage',
options: {
importFrom: {
customProperties: {
'--color-blue': 'blue',
'--color-red': 'red',
'--color': 'var(--color-blue)'
}
}
},
expect: 'import.expect.css',
result: 'import.result.css'
}
}
};
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes to PostCSS color-mod() Function

### 3.0.0 (August 30, 2018)

- Added `importFrom` option which allows you to import Custom Properties from
CSS, JS, and JSON files, and directly passed objects
- Fixed an issue where multiple variables could not be used in `color-mod()`
- Updated to support Node v6+

### 2.4.3 (July 21, 2018)

- Fixed issue with color-mod not being converted within function
Expand Down
170 changes: 170 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Installing PostCSS color-mod() Function

[PostCSS color-mod() Function] runs in all Node environments, with special instructions for:

| [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) |
| --- | --- | --- | --- | --- | --- |

## Node

Add [PostCSS color-mod() Function] to your project:

```bash
npm install postcss-color-mod-function --save-dev
```

Use [PostCSS color-mod() Function] to process your CSS:

```js
const postcssColorMod = require('postcss-color-mod-function');

postcssColorMod.process(YOUR_CSS /*, processOptions, pluginOptions */);
```

Or use it as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssColorMod = require('postcss-color-mod-function');

postcss([
postcssColorMod(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```

## PostCSS CLI

Add [PostCSS CLI] to your project:

```bash
npm install postcss-cli --save-dev
```

Use [PostCSS color-mod() Function] in your `postcss.config.js` configuration file:

```js
const postcssColorMod = require('postcss-color-mod-function');

module.exports = {
plugins: [
postcssColorMod(/* pluginOptions */)
]
}
```

## Webpack

Add [PostCSS Loader] to your project:

```bash
npm install postcss-loader --save-dev
```

Use [PostCSS color-mod() Function] in your Webpack configuration:

```js
const postcssColorMod = require('postcss-color-mod-function');

module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
{ loader: 'postcss-loader', options: {
ident: 'postcss',
plugins: () => [
postcssColorMod(/* pluginOptions */)
]
} }
]
}
]
}
}
```

## Create React App

Add [React App Rewired] and [React App Rewire PostCSS] to your project:

```bash
npm install react-app-rewired react-app-rewire-postcss --save-dev
```

Use [React App Rewire PostCSS] and [PostCSS color-mod() Function] in your
`config-overrides.js` file:

```js
const reactAppRewirePostcss = require('react-app-rewire-postcss');
const postcssColorMod = require('postcss-color-mod-function');

module.exports = config => reactAppRewirePostcss(config, {
plugins: () => [
postcssColorMod(/* pluginOptions */)
]
});
```

## Gulp

Add [Gulp PostCSS] to your project:

```bash
npm install gulp-postcss --save-dev
```

Use [PostCSS color-mod() Function] in your Gulpfile:

```js
const postcss = require('gulp-postcss');
const postcssColorMod = require('postcss-color-mod-function');

gulp.task('css', () => gulp.src('./src/*.css').pipe(
postcss([
postcssColorMod(/* pluginOptions */)
])
).pipe(
gulp.dest('.')
));
```

## Grunt

Add [Grunt PostCSS] to your project:

```bash
npm install grunt-postcss --save-dev
```

Use [PostCSS color-mod() Function] in your Gruntfile:

```js
const postcssColorMod = require('postcss-color-mod-function');

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
postcss: {
options: {
use: [
postcssColorMod(/* 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 color-mod() Function]: https://github.com/jonathantneal/postcss-color-mod-function
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
[React App Rewired]: https://github.com/timarney/react-app-rewired

0 comments on commit 6a1a6fc

Please sign in to comment.