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

ember-cli-less

v3.0.2

Published

Use less to preprocess your ember-cli app css

Downloads

35,923

Readme

ember-cli-less

Use Less to preprocess your ember-cli app's css.

npm version Ember Observer Score Build Status

Compatibility

  • Ember.js v3.12 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

npm install --save-dev ember-cli-less

Usage

By default, this addon will compile app/styles/app.less into dist/assets/app.css. Additional options can be specified using the lessOptions config property in ember-cli-build.js:

let app = new EmberApp({
  lessOptions: {...}
});

Available Options:

  • paths: An array of include paths
  • sourceMap: Whether to generate source maps. Defaults to true in development and can also take an object of sub options: http://lesscss.org/usage/#programmatic-usage
  • mergeTrees: An object of the available options to pass to the internal merge trees plugin

Configuring Input/Output Paths

You can configure the input and output files using ember-cli's outputPaths option in ember-cli-build.js:

let app = new EmberApp({
  outputPaths: {
    app: {
      css: {
        app: '/assets/my-project.css',
      },
    },
  },
});

You can also configure multiple input/output paths to generate multiple css files:

let app = new EmberApp({
  outputPaths: {
    app: {
      css: {
        'theme-orange': '/assets/theme-orange.css',
        'theme-purple': '/assets/theme-purple.css',
      },
    },
  },
});

Notice that you cannot specify the name of the Source Map if multiple input/output paths are used. The name gets generated from the output path (/assets/theme-orange.css -> /assets/theme-orange.css.map).

Usage in Addons

You can also use this to precompile less files in an addon. By default, this will compile addon/styles/addon.less into css that will be merged into the host app's css:

  1. Install ember-cli-less in your addon's package.json under dependencies
  2. Create your addon less file at addon/styles/addon.less (or where you specify in your options)
  3. To run the addon's dummy app, be sure to create tests/dummy/app/styles/app.less if it doesn't exist
  4. To make less files available for applications that consume this addon, create app/styles/app.less in your addon and add @import 'addon/styles/addon'; to its content

To include custom css files, use @import statment in addon/styles/addon.less. For example:

// addon/styles/addon.less
@import 'node_modules/bootstrap-less/bootstrap/bootstrap'; // look for "node_modules/bootstrap-less/bootstrap/bootstrap.less"

Examples

Using Bootstrap Less source in your app:

Install Bootstrap source:

npm install --save-dev bootstrap-less

Specify the include paths in ember-cli-build.js:

let app = new EmberApp({
  lessOptions: {
    paths: ['node_modules/bootstrap-less/bootstrap/'],
  },
});

Import into app.less:

@import 'bootstrap';

Linking source maps

When sourcemaps are enabled, you'll see the correct references to the original less files and their corresponding line numbers in Dev Tools. If you would like to link the less source files directly, you have to link them to your local filesystem in Chrome:

  1. Open dev tools > Sources tab
  2. Expand the sources pane on the left if it's not open
  3. Right-click anywhere, Add folder to workspace, add your project's folder
  4. Locate any less source file in the tree, right-click, Map to Network Resource... to create the mapping

Contributing

See the Contributing guide for details.

References