GithubHelp home page GithubHelp logo

jakesidsmith / watch-less-do-more Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 431 KB

Watch less files and their dependency tree for changes & automatically recompile

Home Page: https://www.npmjs.com/package/watch-less-do-more

JavaScript 100.00%
less css watch watcher postcss postcss-modules dependency-tree recompile

watch-less-do-more's Introduction

watch-less-do-more CircleCI

Watch less files and their dependency tree for changes & automatically recompile

About

Rather than watching a directory for changes in any files, like other watchers, watch-less-do-more watches your main less file and automatically watches only its dependencies. If the main file, or any of it's dependencies change, the main file is compiled. This also allows you to watch multiple main files in a directory, and only compile the ones that have either changed themselves, or have had their dependencies changed. Additionally, this means that updating your node_modules (if any are dependencies of your less) will cause your less to recompile.

Example

If we have the following files

main-a.less
main-b.less
dependency-of-a.less
dependency-of-b.less
dependency-of-a-and-b.less
not-related-to-other-files.less

And we run the command

watch-less-do-more -i main-a.less -o main-a.css -i main-b.less -o main-b.css
  • Changes to not-related-to-other-files.less will not cause any less to compile.

  • Changes to dependency-of-a-and-b.less will cause both main-a.less and main-b.less to recompile.

  • Changes to dependency-of-a.less will cause only main-a.less to recompile.

  • Changes to dependency-of-b.less will cause only main-b.less to recompile.

Install

Install watch-less-do-more. You'll also need to install less. Currently supports less 2.x.x.

npm install watch-less-do-more less --save

Optionally install postcss if you want to use postcss modules. Currently supports postcss 5.x.x.

npm install postcss --save

Usage

In these examples we're adding a script to our package.json

Single main file

{
  "watch-less": "watch-less-do-more -i source.less -o output.css"
}

Multiple main files

You can define as many files as you like, as long as there is an output argument for every input file

{
  "watch-less": "watch-less-do-more -i source-a.less -o output-a.css -i source-b.less -o output-b.css"
}

PostCSS

You can use PostCSS modules with watch-less-do-more incredibly easily. Just install the modules you want, and tell watch-less-do-more to use them in the same way you would with PostCSS.

{
  "watch-less": "watch-less-do-more -u autoprefixer -i source.less -o output.css"
}

Options

--input, -i   Path to input LESS file                      [string] [required]
--output, -o  Path to output CSS file                      [string] [required]
--use, -u     PostCSS module to use                                   [string]
--help        Show help                                              [boolean]
--version     Show version number                                    [boolean]

watch-less-do-more's People

Contributors

jakesidsmith avatar snyk-bot avatar

Stargazers

 avatar

Watchers

 avatar  avatar

watch-less-do-more's Issues

Fails to watch changes on files with special characters in their path

I added a log of output.imports inside parseFileAndWatchImports in watch-less-do-more source. My project returns some relative paths (for node_modules), and some absolute paths (for my own files). My directory contains /{{directory}}/my-file.less characters, and these seem to prevent updates.

Ditch yargs for jargs

Yargs is changing far too regularly (and doesn't really have a nice API, IMO).

The current version has vulnerabilities and needs upgrading, so may as well switch to jargs instead.

--once

Add --once option to compile the less a single time & then exit, without adding any watchers.

This gives users the ability to adopt watch-less-do-more as their main less build tool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.