Coder Social home page Coder Social logo

sbt-stylus's Introduction

sbt-stylus

Build Status

Note that this plugin is presently only working with an engineType set to Node e.g.: set JsEngineKeys.engineType := JsEngineKeys.EngineType.Node

Allows stylus to be used from within sbt. Builds on com.typesafe.sbt:js-engine in order to execute the stylus 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-stylus" % "1.0.1")

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 some of the same options to be specified as the (stylus CLI itself)[http://learnboost.github.io/stylus/docs/executable.html]. Here are the options:

Option Description
compress Compress output by removing some whitespaces.
useNib Adds nib dependency

Use Nib:

StylusKeys.useNib in Assets := true
@import 'nib'

div
  box-shadow: 2px 2px 2px #000

will compile to:

div {
  -webkit-box-shadow: 2px 2px 2px #000;
  box-shadow: 2px 2px 2px #000;
}

Compression

The following sbt code illustrates how compression can be enabled:

StylusKeys.compress in Assets := true

File filters

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

includeFilter in (Assets, StylusKeys.stylus) := "foo.styl" | "bar.styl"

...where both foo.styl and bar.styl will be considered for the Stylus compiler.

Alternatively you may want a more general expression to exclude Stylus files that are not considered targets for the compiler. Quite commonly, Stylus 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 Stylus files. For example, you may have a convention where any Stylus file starting with an _ should not be considered for direct compilation. To include all .styl files but exclude any beginning with an _ you can use the following declaration:

includeFilter in (Assets, StylusKeys.stylus) := "*.styl"

excludeFilter in (Assets, StylusKeys.stylus) := "_*.styl"

© Typesafe Inc., 2014

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.