Linux command
autoprefixer 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Process a CSS file and add vendor prefixes
autoprefixer [input.css] -o [output.css]
Process CSS from stdin
cat [input.css] | autoprefixer > [output.css]
Specify browser targets
autoprefixer [input.css] -o [output.css] --browsers "last 2 versions, > 1%"
Process multiple files in place
autoprefixer [file1.css] [file2.css]
Generate source maps
autoprefixer [input.css] -o [output.css] --map
Show which prefixes would be added
autoprefixer --info
说明
Autoprefixer is a PostCSS plugin that automatically adds vendor prefixes to CSS properties based on current browser usage data. It parses CSS and adds prefixes like -webkit-, -moz-, and -ms- where needed for cross-browser compatibility. The tool uses Browserslist to determine which prefixes are needed based on target browser specifications. It not only adds required prefixes but also removes outdated ones that are no longer necessary, keeping CSS clean and efficient. Autoprefixer handles CSS properties, values, at-rules, and selectors. It understands which browsers support which features and adds only the necessary prefixes based on the specified browser targets, typically configured in a browserslist file or package.json.
参数
- -o, --output _file_
- Write output to the specified file.
- -d, --dir _directory_
- Output to a directory (for multiple files).
- --map
- Generate source maps.
- --no-map
- Disable source map generation.
- -b, --browsers _list_
- Browser targets (Browserslist query).
- --ignore _pattern_
- Glob patterns for files to ignore.
- --replace
- Modify files in place (default for multiple files).
- --info
- Display browser list and prefixes information.
- --no-inline
- Do not inline source maps.
- --env _environment_
- Specify Browserslist environment.
FAQ
What is the autoprefixer command used for?
Autoprefixer is a PostCSS plugin that automatically adds vendor prefixes to CSS properties based on current browser usage data. It parses CSS and adds prefixes like -webkit-, -moz-, and -ms- where needed for cross-browser compatibility. The tool uses Browserslist to determine which prefixes are needed based on target browser specifications. It not only adds required prefixes but also removes outdated ones that are no longer necessary, keeping CSS clean and efficient. Autoprefixer handles CSS properties, values, at-rules, and selectors. It understands which browsers support which features and adds only the necessary prefixes based on the specified browser targets, typically configured in a browserslist file or package.json.
How do I run a basic autoprefixer example?
Run `autoprefixer [input.css] -o [output.css]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -o, --output _file_ do in autoprefixer?
Write output to the specified file.