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

less-watch-compiler

v1.16.3

Published

A command that watches folders(and subfolders) for file changes and automatically compile the less css files into css. This is a file system watcher and compiler.

Downloads

96,117

Readme

CircleCI npm version Dependencies devDependency Status Commitizen friendly Backers on Open Collective Sponsors on Open Collective

Dead Simple LESS CSS Watch Compiler

A command that watches folders(and subfolders) for file changes and automatically compile the less css files into css. This is a file system watcher and compiler. It also keep track of a dependency tree and recompiles the parent if an imported (child) LESS file is changed.

Parts of this script is modified from Mikeal Rogers's watch script (https://github.com/mikeal/watch)

Prerequisites

The commands below may need to be prefixed with sudo depending upon your system

Install LESS and make sure the lessc binary is accessible to the script. Installing LESS with the -g(global) flag will make the binary accessible to your system.

yarn

yarn global add less

npm

npm install -g less

Installation

The commands below may need to be prefixed with sudo depending upon your system

Install the less-watch-compiler command globally.

yarn

yarn global add less-watch-compiler

npm

npm install -g less-watch-compiler

Usage

With no main file

You need to pass in the minimum 2 parameters - <source_dir> and <destination_dir> . First parameter is the source folder to watch for changes and second is the output folder in which the css files will be compiled

Usage:

less-watch-compiler [options] <source_dir> <destination_dir>

With main file

If you pass in the 3rd optional parameter, Any file change will trigger only to compile the main file specified in the 3rd parameter. Assuming the 3rd is "main.less"

Usage:

less-watch-compiler [options] <source_dir> <destination_dir> [main-file]

Basic example

 root 
 └──src
 │    └── main.less
 │    └── aux.less
 └──dist
      └── main.css

The project can be compiled with the following command:

less-watch-compiler src dist main.less

Configuration File

By default the the configuration file is loaded from ./less-watch-compiler.config.json but can also be specified by the --config option.

Example using the project tree laid out in the previous example

less-watch-compiler.config.json

{
    "watchFolder": "src",
    "outputFolder": "dist",
    "mainFile": "main.less"
}

The project can be compiled with the following command:

less-watch-compiler

All configuration file options

{
    "watchFolder": "<input_folder>",   
    "outputFolder": "<output_folder>",
    "mainFile": "<main-file>",   
    "includeHidden": false,
    "sourceMap": false,
    "plugins": "plugin1,plugin2",
    "lessArgs": "option1=1,option2=2",
    "runOnce": false,
    "enableJs": true
}

Options:

-h, --help                                                               output usage information
-V, --version                                                            output the version number
--main-file <file>                                                       Specify <file> as the file to always re-compile e.g. '--main-file style.less'.
--config <file>                                                          Custom configuration file path. (default: "less-watch-compiler.config.json")
--run-once                                                               Run the compiler once without waiting for additional changes.
--include-hidden                                                         Don't ignore files beginning with a '.' or a '_'
--enable-js                                                              Less.js Option: To enable inline JavaScript in less files.
--source-map                                                             Less.js Option: To generate source map for css files.
--plugins <plugin-a>,<plugin-b>                                          Less.js Option: To specify plugins separated by commas.
--less-args <less-arg1>=<less-arg1-value>,<less-arg1>=<less-arg2-value>  Less.js Option: To specify any other less options e.g. '--less-args math=strict,strict-units=on,include-path=./dir1\;./dir2'.

Please note:

  • By default, "minified" is turned on to always compress/minify output. You can set the minification to false by adding "minified":false in the config file.
  • By default, "sourceMap" is turned off. You can generating sourcemap to true by adding "sourceMap":true in the config file.
  • By default, this script only compiles files with .less extension. More file extensions can be added by modifying the allowedExtensions array in config.json.
  • Files that start with underscores _style.css or period .style.css are ignored. This behavior can be changed by adding "includeHidden:true in the config file.
  • When --run-once used, compilation will fail on first error

Using the source files

Alternativelly, you can checkout the code and run things locally like this:

node less-watch-compiler.js [options]

To run unit tests: yarn test or npm test (see test/test.js).

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]