GithubHelp home page GithubHelp logo

sbt-less's Introduction

sbt-less

Build Status Download

Allows less to be used from within sbt. Builds on com.typesafe.sbt:js-engine in order to execute the less compiler along with the scripts to verify. js-engine enables high performance linting given parallelism and native JS engine execution.

To use this plugin use the addSbtPlugin command within your project's plugins.sbt (or as a global setting) i.e.:

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")

Your project's build file also needs to enable sbt-web plugins. For example with build.sbt:

lazy val root = (project in file(".")).enablePlugins(SbtWeb)

The compiler allows most of the same options to be specified as the lessc CLI itself. Here are the options:

Option Description
cleancss Compress output using clean-css.
cleancssOptions Pass an option to clean css, using CLI arguments from https://github.com/GoalSmashers/clean-css .
color Whether LESS output should be colorised
compress Compress output by removing some whitespaces.
globalVariables Variables that will be placed at the top of the less file.
ieCompat Do IE compatibility checks.
insecure Allow imports from insecure https hosts.
maxLineLen Maximum line length.
modifyVariables Modifies a variable already declared in the file.
optimization Set the parser's optimization level.
relativeImports Re-write import paths relative to the base less file. Default is true.
relativeUrls Re-write relative urls to the base less file.
rootpath Set rootpath for url rewriting in relative imports and urls.
silent Suppress output of error messages.
sourceMap Outputs a v3 sourcemap.
sourceMapFileInline Whether the source map should be embedded in the output file
sourceMapLessInline Whether to embed the less code in the source map
sourceMapRootpath Adds this path onto the sourcemap filename and less file paths.
strictImports Whether imports should be strict.
strictMath Requires brackets. This option may default to true and be removed in future.
strictUnits Whether all unit should be strict, or if mixed units are allowed.
urlArgs Adds params into url tokens (e.g. 42, cb=42 or 'a=1&b=2').
verbose Be verbose.

The following sbt code illustrates how compression can be enabled:

LessKeys.compress in Assets := true

By default only main.less is looked for given that the LESS compiler must be explicitly fed the files that are required for compilation. Beyond just main.less, you can use an expression in your build.sbt like the following:

includeFilter in (Assets, LessKeys.less) := "foo.less" | "bar.less"

...where both foo.less and bar.less will be considered for the LESS compiler.

Alternatively you may want a more general expression to exclude LESS files that are not considered targets for the compiler. Quite commonly, LESS files are divided up into those entry point files and other files, with the latter set intended for importing into the entry point files. These other files tend not to be suitable for the compiler in isolation as they can depend on the global declarations made by other non-imported LESS files. For example, you may have a convention where any LESS file starting with an _ should not be considered for direct compilation. To include all .less files but exclude any beginning with an _ you can use the following declaration:

includeFilter in (Assets, LessKeys.less) := "*.less"

excludeFilter in (Assets, LessKeys.less) := "_*.less"

© Typesafe Inc., 2013, 2014

sbt-less's People

Contributors

adamhooper avatar akosicki avatar asazernik avatar benmccann avatar blobson avatar danielnixon avatar eecolor avatar gmethvin avatar huntc avatar jroper avatar jtjeferreira avatar micmro avatar mkurz avatar n4to4 avatar pvlugter avatar randak avatar richdougherty avatar tkawachi avatar warry avatar yatskevich avatar

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.