Skip to content

Latest commit

 

History

History
235 lines (182 loc) · 3.9 KB

INSTALL.md

File metadata and controls

235 lines (182 loc) · 3.9 KB

Installing PostCSS Place Properties

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

Node

Add PostCSS Place Properties to your project:

npm install postcss postcss-place --save-dev

Use it as a PostCSS plugin:

// commonjs
const postcss = require('postcss');
const postcssPlace = require('postcss-place');

postcss([
	postcssPlace(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
// esm
import postcss from 'postcss';
import postcssPlace from 'postcss-place';

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

PostCSS CLI

Add PostCSS CLI to your project:

npm install postcss-cli postcss-place --save-dev

Use PostCSS Place Properties in your postcss.config.js configuration file:

const postcssPlace = require('postcss-place');

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

PostCSS Load Config

If your framework/CLI supports postcss-load-config.

npm install postcss-place --save-dev

package.json:

{
	"postcss": {
		"plugins": {
			"postcss-place": {}
		}
	}
}

.postcssrc.json:

{
	"plugins": {
		"postcss-place": {}
	}
}

See the README of postcss-load-config for more usage options.

Webpack

Webpack version 5

Add PostCSS Loader to your project:

npm install postcss-loader postcss-place --save-dev

Use PostCSS Place Properties in your Webpack configuration:

module.exports = {
	module: {
		rules: [
			{
				test: /\.css$/i,
				use: [
					"style-loader",
					{
						loader: "css-loader",
						options: { importLoaders: 1 },
					},
					{
						loader: "postcss-loader",
						options: {
							postcssOptions: {
								plugins: [
									// Other plugins,
									[
										"postcss-place",
										{
											// Options
										},
									],
								],
							},
						},
					},
				],
			},
		],
	},
};

Next.js

Read the instructions on how to customize the PostCSS configuration in Next.js

npm install postcss-place --save-dev

Use PostCSS Place Properties in your postcss.config.json file:

{
	"plugins": [
		"postcss-place"
	]
}
{
	"plugins": [
		[
			"postcss-place",
			{
				// Optionally add plugin options
			}
		]
	]
}

Gulp

Add Gulp PostCSS to your project:

npm install gulp-postcss postcss-place --save-dev

Use PostCSS Place Properties in your Gulpfile:

const postcss = require('gulp-postcss');
const postcssPlace = require('postcss-place');

gulp.task('css', function () {
	var plugins = [
		postcssPlace(/* pluginOptions */)
	];

	return gulp.src('./src/*.css')
		.pipe(postcss(plugins))
		.pipe(gulp.dest('.'));
});

Grunt

Add Grunt PostCSS to your project:

npm install grunt-postcss postcss-place --save-dev

Use PostCSS Place Properties in your Gruntfile:

const postcssPlace = require('postcss-place');

grunt.loadNpmTasks('grunt-postcss');

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