Coder Social home page Coder Social logo

browserify-postcss's Introduction

browserify-postcss

version status dependencies devDependencies

A browserify transform to work with postcss.

Example

The build script:

var browserify = require('browserify')
var fs = require('fs')

var b = browserify(__dirname + '/src/entry.js')
b.transform('browserify-postcss', {
  // a list of postcss plugins
  plugin: [
    'postcss-import',
    'postcss-advanced-variables',
    ['postcss-custom-url', [
      ['inline', { maxSize: 10 }],
      ['copy', {
        assetOutFolder: __dirname + '/static/assets',
        baseUrl: 'assets',
        name: '[name].[hash]',
      }],
    ]],
  ],
  // basedir where to search plugins
  basedir: __dirname + '/src',
  // insert a style element to apply the styles
  inject: true,
})
b.bundle().pipe(
  fs.createWriteStream(to)
)

entry.js:

require('./entry.css')

console.log('styles from entry.css are applied')

Options

plugin

Specify a list of postcss plugins to apply.

Type: String, Array Default: null

basedir

Specify where to look for plugins.

postCssOptions

Specify the options for the postcss processor.

The from and to fields will be set to the css file path by default.

The to option is used to calculated url() in the final styles. However, if your postcss plugin does not need it, don't bother to specify.

inject

Specify how to use the styles:

If true, styles are applied immediately. If false, require('style.css') will return the string representation of the styles.

extensions

A list of file extensions to identify styles.

Type: Array

Default: ['.css', '.scss', '.sass']

Watch

Imported files will NOT be watched when used with watchify.

Related

  • reduce-css: bundle css files without requireing them in js.

browserify-postcss's People

Contributors

ilyhakudrya avatar ondratra avatar stefanpearson avatar zoubin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.