Linux command
sass 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile SCSS to CSS
sass [input.scss] [output.css]
Watch for changes
sass --watch [input.scss]:[output.css]
Watch directory
sass --watch [src/scss]:[dist/css]
Compile without source maps
sass --no-source-map [input.scss] [output.css]
Compile compressed
sass --style=compressed [input.scss] [output.css]
Compile from stdin
sass --stdin --style=compressed
Use specific load path
sass --load-path=[node_modules] [input.scss] [output.css]
说明
Sass (Syntactically Awesome Style Sheets) is a CSS preprocessor adding variables, nesting, mixins, and other features. It compiles to standard CSS for browser use. Two syntaxes exist: SCSS (Sassy CSS, .scss) uses CSS-like braces and semicolons; Sass (.sass) uses indentation. SCSS is more popular for its CSS compatibility. Variables ($color: #333) enable reusable values. Nesting reflects HTML structure in styles. Mixins (@mixin, @include) share reusable style patterns. Functions perform calculations and transformations. Imports (@use, @import) compose styles from multiple files. The @use rule provides namespaced access and better encapsulation than legacy @import. Watch mode monitors files for changes, automatically recompiling. This enables rapid development with live reload tools. Source maps connect compiled CSS to original Sass for debugging. Output styles control formatting: expanded for development, compressed for production.
参数
- --watch
- Watch for changes and recompile.
- --style _STYLE_
- Output style: expanded, compressed.
- --source-map
- Generate source map.
- --no-source-map
- Disable source maps.
- --load-path _PATH_
- Path to find imports.
- --charset
- Emit @charset for non-ASCII.
- --no-charset
- Don't emit @charset.
- --error-css
- Emit error in CSS output.
- --update
- Only compile changed files.
- --stop-on-error
- Stop after first error.
- --color / --no-color
- Color output control.
- --quiet
- Suppress warnings.
- --trace
- Show full stack trace on error.
- --stdin
- Read from stdin.
- --indented
- Parse stdin as indented syntax.
FAQ
What is the sass command used for?
Sass (Syntactically Awesome Style Sheets) is a CSS preprocessor adding variables, nesting, mixins, and other features. It compiles to standard CSS for browser use. Two syntaxes exist: SCSS (Sassy CSS, .scss) uses CSS-like braces and semicolons; Sass (.sass) uses indentation. SCSS is more popular for its CSS compatibility. Variables ($color: #333) enable reusable values. Nesting reflects HTML structure in styles. Mixins (@mixin, @include) share reusable style patterns. Functions perform calculations and transformations. Imports (@use, @import) compose styles from multiple files. The @use rule provides namespaced access and better encapsulation than legacy @import. Watch mode monitors files for changes, automatically recompiling. This enables rapid development with live reload tools. Source maps connect compiled CSS to original Sass for debugging. Output styles control formatting: expanded for development, compressed for production.
How do I run a basic sass example?
Run `sass [input.scss] [output.css]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --watch do in sass?
Watch for changes and recompile.