← Back to sass/sass

How to Deploy & Use sass/sass

Sass Deployment and Usage Guide

Prerequisites

  • Node.js (for npm-based installation) or Dart SDK (for Dart Sass)
  • Command Line Interface (Terminal or Command Prompt)
  • Git (for cloning the repository)

Installation

Option 1: Install via npm (JavaScript implementation)

npm install -g sass

Option 2: Install Dart Sass (recommended for better performance)

  1. Download the appropriate package for your operating system from the GitHub releases page
  2. Add the downloaded executable to your system's PATH
  3. Verify installation by running:
sass --version

Option 3: Clone and Build from Source

# Clone the repository
git clone https://github.com/sass/sass.git
cd sass

# Install dependencies
npm install

# Build the project
npm run build

Configuration

Environment Variables

No specific environment variables are required for basic Sass usage.

Configuration Files

Sass does not require configuration files for basic usage. However, you can create a sass.config.js file for advanced configuration if needed.

API Keys

No API keys are required for Sass compilation.

Build & Run

Compiling Sass to CSS

# Basic compilation
sass input.scss output.css

# Watch mode (automatically recompile on changes)
sass --watch input.scss output.css

# Compile entire directory
sass src/stylesheets/ build/stylesheets/

# Watch entire directory
sass --watch src/stylesheets/:build/stylesheets/

Development

For development, use the watch mode to automatically compile your Sass files as you make changes:

sass --watch scss:css

Production

For production builds, you can use the standard compilation command. Consider adding minification using a build tool like Webpack or Gulp.

Deployment

Sass is a CSS preprocessor, so deployment typically involves:

  1. Compiling your .scss or .sass files to .css
  2. Including the generated .css files in your web application

Recommended Deployment Platforms

  • Static Site Generators: Vercel, Netlify, GitHub Pages
  • Node.js Applications: Heroku, Railway, AWS Elastic Beanstalk
  • Docker: Containerize your application with compiled CSS

Example: Deploying to Vercel

# Compile your Sass files
sass src/stylesheets/ public/stylesheets/

# Deploy your application
vercel --prod

Troubleshooting

Common Issues and Solutions

1. "Command not found: sass"

Solution: Ensure Sass is installed and added to your PATH. For npm installations, try reinstalling with npm install -g sass. For Dart Sass, verify the executable is in your PATH.

2. Syntax Errors in Sass Files

Solution: Check your Sass syntax. Common issues include:

  • Missing semicolons
  • Incorrect nesting
  • Undefined variables

3. Performance Issues

Solution: If using the JavaScript implementation and experiencing slow compilation, consider switching to Dart Sass for better performance.

4. Import Path Issues

Solution: Verify your import paths are correct. Use relative paths or configure include paths:

sass --load-path=node_modules input.scss output.css

5. Watching Multiple Directories

Solution: Use the directory watching syntax:

sass --watch src/stylesheets/:dist/stylesheets/

6. Version Compatibility

Solution: Ensure your Sass version is compatible with your project requirements. Check the version with sass --version and update if necessary.

Getting Help