Skip to content

Latest commit

 

History

History
149 lines (112 loc) · 2.96 KB

INSTALL.md

File metadata and controls

149 lines (112 loc) · 2.96 KB

Installing PostCSS Gray

PostCSS Gray runs in all Node environments, with special instructions for:

Node Webpack Create React App Gulp Grunt

Node

Add PostCSS Gray to your project:

npm install postcss-color-gray --save-dev

Use PostCSS Gray to process your CSS:

import postcssGray from 'postcss-color-gray';

postcssGray.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

import postcss from 'postcss';
import postcssGray from 'postcss-color-gray';

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

Webpack

Add PostCSS Loader to your project:

npm install postcss-loader --save-dev

Use PostCSS Gray in your Webpack configuration:

import postcssGray from 'postcss-color-gray';

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

Create React App

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

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

Use React App Rewire PostCSS and PostCSS Gray in your config-overrides.js file:

import reactAppRewirePostcss from 'react-app-rewire-postcss';
import postcssGray from 'postcss-color-gray';

export default config => reactAppRewirePostcss(config, {
  plugins: () => [
    postcssGray(/* pluginOptions */)
  ]
});

Gulp

Add Gulp PostCSS to your project:

npm install gulp-postcss --save-dev

Use PostCSS Gray in your Gulpfile:

import postcss from 'gulp-postcss';
import postcssGray from 'postcss-color-gray';

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

Grunt

Add Grunt PostCSS to your project:

npm install grunt-postcss --save-dev

Use PostCSS Gray in your Gruntfile:

import postcssGray from 'postcss-color-gray';

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
  postcss: {
    options: {
      use: [
       postcssGray(/* pluginOptions */)
      ]
    },
    dist: {
      src: '*.css'
    }
  }
});