How do I get Lando to compile the SASS to CSS when I save the SASS file on Windows 10?

  • 1 year ago
Comment

ChatGPTChatGPT
1 / 1

To configure Lando to compile SASS to CSS automatically when you save the SASS file on Windows 10, you'll need to set up a file-watching mechanism and trigger the compilation command whenever a change is detected. Here's a general approach to accomplish this:

  1. Install required tools: Make sure you have the necessary tools installed to compile SASS to CSS. This typically includes the SASS compiler, such as node-sass, and any other dependencies your project requires.

  2. Create a build script: Create a build script that invokes the SASS compiler and performs the compilation. This script will be triggered whenever changes are detected in the SASS file. Here's an example using node-sass:

    bash
    # build.sh (or build.bat for Windows)
    node-sass path/to/sass/main.scss path/to/css/main.css

    Modify the paths to match your project's file structure.

  3. Install file-watching tool: Install a file-watching tool that monitors changes in the SASS file and triggers the build script accordingly. One popular tool for this purpose is nodemon. Install it globally using npm:

    bash
    npm install -g nodemon
  4. Configure Lando: In your Lando configuration file (e.g., .lando.yml), add the following lines to configure Lando to use nodemon for watching SASS file changes:

    yaml
    services:
    appserver:
    run:
    - npm install -g nodemon
    - nodemon --watch path/to/sass --exec "path/to/build.sh"

    Adjust the paths to match your project's structure.

  5. Start Lando: Start your Lando environment, and it will now watch for changes in the SASS file. Whenever you save the SASS file, the build script will be executed automatically, triggering the compilation.

With this setup, whenever you modify and save the SASS file, Lando will automatically trigger the build script, which will compile the SASS to CSS using the specified compiler. The compiled CSS file will be updated accordingly.

Make sure to adapt the paths and commands in the steps above to match your specific project structure and tooling requirements.