npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

scss-import-watcher

v1.1.0

Published

Automatically watch selected folder/nested folders and update SCSS import statements in selected styles file

Downloads

34

Readme

⚡️ SCSS Import Watcher

A powerful and intuitive command-line interface tool designed to automate the management of your SCSS @import statements. Say goodbye to manually adding or removing imports as your project structure evolves! This tool is particularly helpful for projects utilizing SCSS partials alongside modern build tools like Vite, Webpack, or Rollup, which often rely on a single entry point for your SCSS.


✨ Features

This CLI simplifies your SCSS workflow by automatically generating and maintaining @import statements in your main SCSS file(s) based on the contents of your watched directories.

  • Interactive Setup: A user-friendly command-line interface guides you through the setup process.
  • Project Root Definition: Define a central root directory for your SCSS project.
  • Flexible Watcher Creation:
    • Create watchers for any subfolder within your project root.
    • Specify a single SCSS file at the root level (e.g., main.scss, styles.scss) where all generated @import statements will be placed.
    • Intelligent Import Management: Automatically generates and updates @import statements for all .scss files found within your watched directories.
  • Custom Marker Support: Users can define their own custom start and end marker comments in the target SCSS file. The CLI will detect and utilize these user-defined markers to manage @import statements, ensuring they stay in their desired location.
    • Marker Syntax: These markers must be valid SCSS comments. Each pair of start and end markers is directly associated with a specific watcher's folder. They must follow this exact format:
      /* [FOLDER_NAME] import start */
      @import 'example';
      /* [[FOLDER_NAME] import end */
      Ensure these marker pairs are unique in your file to avoid conflicts.
  • Automatic Partial Naming: When generating @import statements, the CLI automatically removes the leading underscore from SCSS partial filenames (e.g., _variables.scss becomes @import "variables";).
  • Nested Watcher Exclusions & Organized Imports: This feature intelligently prevents duplicate @import statements when you set up multiple watchers covering overlapping or nested directories.
    • Intelligent Grouping: To prevent redundancy and maintain clarity, the CLI automatically groups imported files by their source folder within your target SCSS file. It inserts comments like // foldername above each group of imports. This internal organization assists the CLI in preventing a file (e.g., _button.scss) from being imported multiple times if its folder and a broader parent folder are both watched.
    • Example Import Structure:
      /* my_main_imports import start */
      /* base */
      @import "base/variables";
      @import "base/mixins";
      
      /* components  */
      @import "components/button";
      @import "components/card";
      
      /* layout */
      @import "layout/grid";
      /* my_main_imports import end */
      In this example, // base, // components, and // layout are the grouping comments.
  • Watcher Management Dashboard:
    • View All Watchers: Get a clear list of all your active watchers, showing their watched folder and target SCSS file.
    • Edit Watchers: Modify an existing watcher's watched folder, target SCSS file, or even its name. The system handles cleanup and relocation of imports accordingly.
    • Delete Watchers: Remove individual watchers or delete all of them. When deleting a watcher, its markers are removed, and imports are left as "floating" (to be cleaned up manually if a new watcher claims them).
  • Clean Exit: Ensures all watchers are gracefully shut down and their markers are removed when you exit the CLI. Generated import statements stay in place.
  • Visual Cues: Uses simple text-based icons (📁, 📄, ↩️) in interactive prompts to enhance readability and navigation.

🚫 Limitations

While powerful, this tool has a few limitations to be aware of:

  • No SCSS Compilation: This tool does not compile your SCSS into CSS. You'll need a separate SCSS compiler (like Node-Sass, Dart Sass, or a build tool like Webpack/Gulp) for that.
  • Directory Watching Only: Watchers monitor entire directories for .scss files; they do not target individual files for specific content.
  • Root-Level Styles File: The target SCSS file where imports are written must reside directly in the root directory you define when starting the CLI (i.e., the "Project Root" you select in the initial prompt). It cannot be in a subfolder of that selected root.
  • SCSS @import Specific: It specifically manages @import statements for SCSS files and does not handle other types of CSS @import or @use rules outside of its scope.

⚠️ Important Considerations

  • Floating Imports After Deletion: When a watcher is deleted, its specific marker comments are removed, but the generated @import statements themselves are retained (they become "floating" imports).
    • If these floating imports are then managed by a newly created or existing watcher for the same content (e.g., you create a new watcher for the exact same folder), the CLI will not automatically re-home them within the new watcher's markers, be mindful for duplicates.

🚀 Getting Started & Usage

1. Project-Specific Installation (Recommended for Project Use)

This method installs the CLI as a development dependency within your project, allowing it to be managed via npm scripts. This is ideal for project-specific automation and ensures consistent versions across your team.

  1. Install the package in your project: Navigate to your project's root directory and install it as a dev dependency:

      npm i -D scss-import-watcher
  2. Add a script to your project's package.json: Open your project's package.json file and add an entry to the "scripts" section to easily run the CLI. I recommend using npx to ensure the locally installed version is executed.

    "scripts": {
      "watch-scss": "npx scss-watcher"
    }

    Remember to use the command name (scss-watcher) that you defined in the bin field of the scss-import-watcher-cli package's package.json.

  3. Run the CLI from your project root:

    npm run watch-scss

📄 License

This project is licensed under the MIT License.


Small Note: This project was developed with significant contributions from an AI language model (e.g., Gemini, ChatGPT).