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

requirejs-less

v0.1.5

Published

Requirejs plugin for less loading

Downloads

93

Readme

require-less

Optimizable LESS requiring with RequireJS

Based on the ideas from require-css module, read the documentation there for further usage instructions.

Basic Overview

Allows the construction of scripts that can require LESS files, using the simple RequireJS syntax:

define(['less!styles/main'], function() {
  //code that requires the stylesheet: styles/main.less
});

When run the in the browser, less is downloaded, parsed and injected. When running a build with the RequireJS optimizer, less is compiled into the build layers dynamically as css with compression support, or into a separate file with the separateCSS build option.

Normalization

By default LESS URIs are normalized relative to the base LESS.

URIs can be made relative to the individual LESS files with the global LESS configuration:

<script>window.less = { relativeUrls: true }</script>

Installation and Setup

Download the require-less folder manually or use Bower:

bower install require-less

Then add the following package configuration in RequireJS:

map: {
  '*': {
    'less': 'require-less/less' // path to less
  }
}

Package configuration can also be used here alternatively.

Builds

Before running a build, install the LESS NodeJS module and csso for compression:

  npm install less csso

NOTE: If you are running the optimizer globally, use npm install less csso -g.

The RequireCSS build system is used to build LESS. The exact same options thus apply.

Example build configuration:

{
  modules: [
    {
      include: ['mymodule'], // where mymodule is dependent on a less! include
      exclude: ['require-css/normalize'],
    }
  ]
}

This inlines all compiled LESS required by mymodule into the build layer for dynamic injection.

To build into a separate CSS file:

  separateCSS: true,
  modules: [
    {
      include: ['mymodule'], // where mymodule is dependent on a less! include
      exclude: ['require-css/normalize'],
    }
  ]

The separateCSS build option can then be used to create this CSS layer as a separate file. See the RequireCSS documentation for more information.

Compilation Options

Compilation options can be set with the less configuration option in the RequireJS config:

requirejs.config({
  less: {
    // ... custom LESS compiler options ...
    // for example: relativeUrls: true
  }
});

License

MIT

Bitdeli Badge