lix-website/themes/lix/assets/bootstrap/node_modules/postcss-syntax
2024-04-26 22:49:34 -06:00
..
document.js initial commit of template 2024-04-26 22:49:34 -06:00
get-lang.js initial commit of template 2024-04-26 22:49:34 -06:00
get-syntax.js initial commit of template 2024-04-26 22:49:34 -06:00
index.js initial commit of template 2024-04-26 22:49:34 -06:00
LICENSE initial commit of template 2024-04-26 22:49:34 -06:00
load-syntax.js initial commit of template 2024-04-26 22:49:34 -06:00
normal-opts.js initial commit of template 2024-04-26 22:49:34 -06:00
package.json initial commit of template 2024-04-26 22:49:34 -06:00
parse-style.js initial commit of template 2024-04-26 22:49:34 -06:00
parse.js initial commit of template 2024-04-26 22:49:34 -06:00
parser.js initial commit of template 2024-04-26 22:49:34 -06:00
patch-postcss.js initial commit of template 2024-04-26 22:49:34 -06:00
processor.js initial commit of template 2024-04-26 22:49:34 -06:00
README.md initial commit of template 2024-04-26 22:49:34 -06:00
stringify.js initial commit of template 2024-04-26 22:49:34 -06:00
syntax.js initial commit of template 2024-04-26 22:49:34 -06:00

PostCSS Syntax

NPM version Travis Travis Codecov David

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:

If you want support HTML (and HTML-like)/Markdown/CSS-in-JS file format, you need to install these module:

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
});