Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including npm-css with all npm packages installed. Try it out:

var npmCss = require("npm-css")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

npm-css v0.2.3

Require css from npm

npm-css

Require css from node modules.

Syntax

@import "typeahead";

@import "./foo.css";
@import "./bar/baz.css";

.foo {
    color: red
}

npm-css reads css imports in the format of @import " ... " and inlines the CSS at that path for you. It also understands node modules.

If you @import a folder it will try to look for a package.json file or read index.css by default. See the package.json section below.

CLI

To build a single css file from an entry.css with @import statements.

npm-css entry.css -o bundle.css

API

If you want to build css files on the fly.

var npmcss = require('npm-css');
var css = npmcss(/path/to/file);

package.json

You can specify the stylesheet for your module by adding a "style" field to your package.json file. This works similarly to the "main" field.

Installation

npm install npm-css

MIT Licenced

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free