0.36.2 • Published 5 years ago
postcss-syntax v0.36.2
PostCSS Syntax
postcss-syntax can automatically switch the required PostCSS syntax by file extension/source
Getting Started
First thing's first, install the module:
npm install postcss-syntax --save-dev
If you want support SCSS/SASS/LESS/SugarSS syntax, you need to install these module:
- SCSS: postcss-scss
- SASS: postcss-sass
- LESS: postcss-less
- SugarSS: sugarss
If you want support HTML (and HTML-like)/Markdown/CSS-in-JS file format, you need to install these module:
- CSS-in-JS: postcss-jsx
- HTML (and HTML-like): postcss-html
- Markdown: postcss-markdown
Use Cases
const postcss = require('postcss');
const syntax = require('postcss-syntax')({
rules: [
{
test: /\.(?:[sx]?html?|[sx]ht|vue|ux|php)$/i,
extract: 'html',
},
{
test: /\.(?:markdown|md)$/i,
extract: 'markdown',
},
{
test: /\.(?:m?[jt]sx?|es\d*|pac)$/i,
extract: 'jsx',
},
{
// custom language for file extension
test: /\.postcss$/i,
lang: 'scss'
},
{
// custom language for file extension
test: /\.customcss$/i,
lang: 'custom'
},
],
// custom parser for CSS (using `postcss-safe-parser`)
css: 'postcss-safe-parser',
// custom parser for SASS (PostCSS-compatible syntax.)
sass: require('postcss-sass'),
// custom parser for SCSS (by module name)
scss: 'postcss-scss',
// custom parser for LESS (by module path)
less: './node_modules/postcss-less',
// custom parser for SugarSS
sugarss: require('sugarss'),
// custom parser for custom language
custom: require('postcss-custom-syntax'),
});
postcss(plugins).process(source, { syntax: syntax }).then(function (result) {
// An alias for the result.css property. Use it with syntaxes that generate non-CSS output.
result.content
});
0.36.2
5 years ago
0.36.1
5 years ago
0.36.0
5 years ago
0.34.0
6 years ago
0.33.0
6 years ago
0.32.0
6 years ago
0.31.0
6 years ago
0.30.0
6 years ago
0.28.0
6 years ago
0.27.0
6 years ago
0.26.1
6 years ago
0.26.0
6 years ago
0.25.0
6 years ago
0.24.0
6 years ago
0.9.1
6 years ago
0.10.0
6 years ago
0.9.0
6 years ago
0.8.0
6 years ago
0.7.0
6 years ago
0.6.0
6 years ago
0.3.1
6 years ago
0.3.0
6 years ago
0.2.0
6 years ago
0.1.0
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago