Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browserify-css

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserify-css

A Browserify transform for bundling, rebasing, inlining, and minifying CSS files

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.2K
increased by20.38%
Maintainers
1
Weekly downloads
 
Created
Source

browserify-css

A Browserify transform for bundling, rebasing, inlining, and minifying CSS files.

Getting Started

If you're new to browserify, check out the browserify handbook and the resources on browserify.org.

Installation

npm install --save-dev browserify-css

Usage

app.css:

@import url("modules/foo/index.css");
@import url("modules/bar/index.css");
body {
    background-color: #fff;
}

app.js:

var css = require('./app.css');
console.log(css);

You can compile your app by passing -t browserify-css to browserify:

$ browserify -t browserify-css app.js > bundle.js

Each require('./path/to/file.css') call will concatenate CSS files with @import statements, rebasing urls, inlining @import, and minifying CSS. It will add a style tag with an optional data-href attribute to the head section of the document during runtime:

<html>
<head>
    <style type="text/css" data-href="app.css">...</style>
</head>
</html>

Configuration

You can put your browserify-css options into your package.json file:

{
    "browserify-css": {
        "auto-inject": true,
        "minify": true,
        "rootDir": "."
    }
}

or use an external configuration file like below:

{
    "browserify-css": "./config/browserify-css.js"
}

config/browserify-css.js:

module.exports = {
    "auto-inject": true,
    "minify": true,
    "rootDir": "."
};

Options

auto-inject

Type: Boolean Default: true

If true, each require('path/to/file.css') call will add a style tag to the head section of the document.

rootDir

Type: String Default: ./

An absolute path to resolve relative paths against the project's base directory.

minfiy

Type: Boolean Default: false

minify-options

Type: Object Default: {}

Check out a list of CSS minify options at CleanCSS.

License

MIT

Keywords

FAQs

Package last updated on 27 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc