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 🙏

© 2024 – Pkg Stats / Ryan Hefner

lessc-watcher

v1.2.2

Published

A minimal package to watch less files and compile them to css

Downloads

814

Readme

Less watch for .less files

This is a super-light npm package that watches .less files and actively compiles them into .css files


Prerequisites

You need less npm package insalled. you can add it your project by running:

npm install less

Installation

To install this package simply run:

npm install lessc-watcher

How to use

There are few different ways to run your less compiler

Basic usage

npx lessc-watcher --src ./folder --dst ./dist/less.css

This traverses the --src folder and searches for a main.less file. This file serves as the source for your bundled .css file. If you want to target a specific file, use:

npx lessc-watcher --src ./folder/src.less --dst ./dist/less.css

Or you can just watch an entire folder. In this case less-watch will searc for an entry file named main.less. Without this entry file, your compiler wouldn't work.

npx lessc-watcher --src ./folder --dst ./dist/less.css

NOTE: If you only provide a destination path, without specifying the exact file name in .css, your files will be compiled to a css file named _main.css. This is done to prevent conflicts with another possible main.css file.

Adding more source folders

You can add more source folders by using a comma(,) separator. Example:

npx lessc-watcher --src ./folder-1,./folder-2 --dst ./dist/folder-1.css,./dist/folder-2.css

NOTE: Your --dst input must match the number of comma-separated folders in your src input.

Advanced Features

lessc-watcher has more advanced features to better fine-tune your files

Ignore files

Ignore files/folders by enlosing the names in braces. Eg (general).less

Compile specific files

If you're watching an entire folder, you can compile specific files in that folder to a stanalone file. Example if you create a file named [test].less in your watch directory, in your distribution directory there will be an extra file named test.css.

Using a lesscw.config.json file

You can use a lesscw.config.json file to add your files instead of using the CLI interface. For this to work your lesscw.config.json file must be located in the root directory of your project, and it must contain at least one src and one dst entry

Basic Config JSON

{
    "src": "./folder",
    "dst": "./dist/less.css"
}

This works the same as running npx lessc-watcher --src ./folder --dst ./dist/less.css in your terminal. Instead you only need to run:

npx lessc-watcher

Using multiple sources and destinations

{
    "src": ["./folder", "./folder-2", "./folder/sub-folder/admin.less"],
    "dst": ["./dist/less.css", "./dist/folder-2/less.css", "./dist/sub-folder.css"]
}

Like the CLI paradigm, the number of paths in the src array must match the dst array. And note that you can use multiple different folders with multiple different destinations.

Using a srcDst cofiguration

ALternative to the src and dst paths, you can provide a srcDst key instead, this will contain an array of key-value pairs as follows

{
    "srcDst": [
        {
            "src": "./folder",
            "dst": "./folder-2"
        }
    ]
}

NOTE: If you provide a config file and still add --src and --dst arguments in your terminal, the terminal source and distributuion arguments will be ignored.