Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Automatically switch PostCSS syntax based on file extensions

License

NotificationsYou must be signed in to change notification settings

gucong3000/postcss-syntax

Repository files navigation

NPM versionTravisTravisCodecovDavid

postcss-syntax can automatically switch the requiredPostCSS 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

constpostcss=require('postcss');constsyntax=require('postcss-syntax')({rules:[{test:/\.(?:[sx]?html?|[sx]ht|vue|ux|php)$/i,extract:'html',},{test:/\.(?:markdown|md)$/i,extract:'markdown',},{test:/\.(?:[cm]?[jt]sx?|es\d*|pac)$/i,extract:'jsx',},{// custom language for file extensiontest:/\.postcss$/i,lang:'scss'},{// custom language for file extensiontest:/\.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 SugarSSsugarss:require('sugarss'),// custom parser for custom languagecustom: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});

About

Automatically switch PostCSS syntax based on file extensions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp