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-plugin-bower-resolve

v0.1.0

Published

Import Less files from Bower packages

Downloads

14

Readme

less-plugin-bower-resolve

Import Less files from Bower packages

This plugin requires Less in version >= 2.0.0-b2.

Install

$ npm install --save-dev less-plugin-bower-resolve

Usage

Just add --bower-resolve when you use lessc. You can learn more about lessc here. Here is an example:

$ lessc --bower-resolve styles.less styles.css

If you @import a Less file now, it will try to resolve the file from your bower_components/ directory first (or a custom directory, if you use .bowerrc) and fallback to the old behavior, if no Bower package can be found. If you explicitly not want to load a module from bower_components/ you can use absolute or relative paths like @import "./hello/world";. If the Bower packages references multiple Less files in the "main" property of bower.json (or .bower.json or component.json) all of the will be imported.

Let's look at an example. If you have:

@import "my-module";

And you have a my-module/ inside bower_components/ with a bower.json like this:

{
  "main": [
    "src/hello.less",
    "src/world.less"
  ]
}

Than src/hello.less and src/world.less will be imported. Prior to that you would have to do that:

// OLD WAY
@import "bower_components/my-module/src/hello.less";
@import "bower_components/my-module/src/world.less";

This was very error prone as you couldn't know if a Bower package author would rename the src/, hello.less or world.less or if he introduces new files, removes old ones or changes their order.

Anyway - if you really want you can target a specific file inside a Bower package like this:

@import "my-module/src/hello.less";

This will at least stopping you from prepending bower_components/ to your imports. If you distributed a Less file via Bower before and used other packages you know that it's bad to hard-code bower_components/ this way, because you can't customize the directory via .bowerrc anymore.

Testing

Run the tests with $ npm test.