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