Socket
Book a DemoInstallSign in
Socket

csso-next-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csso-next-loader

CSSO loader module for webpack

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

csso-loader

NPM version Build Status Dependency Status NPM downloads Code Climate Test Coverage

CSSO loader module for webpack.

Usage

Documentation: Using loaders

Installation

npm install csso-loader --save-dev

Examples

Using csso-loader with css-loader.

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader',
      }
    ]
  }
};

Advanced options

restructure

Default: true

csso performs structural optimization for better compression by default. Use -restructure in case you want to disable it.

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader?-restructure',
      }
    ]
  }
};

Also it can be disabled by restructure boolean option in csso object of webpack config.

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader',
      }
    ]
  },
  csso: {
    restructure: false
  }
};

debug

Default: false

debug is using to get details about the minification process.

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader?debug',
      }
    ]
  }
};

Also you can set debug option in csso object of webpack config. It can be boolean or a positive number from 1 to 3 (greater number for more details).

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader',
      }
    ]
  },
  csso: {
    debug: 3
  }
};

comments

Default: exclamation or true

csso leave all exclamation comments by default (i.e. /*! .. */). Use '-comments' to remove all comments.

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader?-comments',
      }
    ]
  }
};

Also you can set comments option in csso object of webpack config. It can be boolean or string (use first-exclamation to remove all comments except first one with exclamation).

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader',
      }
    ]
  },
  csso: {
    comments: 'first-exclamation'
  }
};

usage

With usage option you can set data about CSS usage. For example, white lists (tags, ids and classes) can be set to filter unused selectors and related CSS rules as well. See Usage data in csso documentation for more details.

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader',
      }
    ]
  },
  csso: {
    usage: {
      tags: ['span', 'div'],
      ids: ['id1'],
      classes: ['class1', 'class2', 'class3', 'class4']
      scopes: [
        ['class1', 'class2'],
        ['class3', 'class4']
      ]
    }
  }
};

logger

To log how CSS is transforming through compression stages use logger option. First argument is a stage name, and second one is AST of current state CSS or null.

module.exports = {
  ...
  module: {
    loaders: [
      {
        test: /\.css$/,
        loader: 'css-loader!csso-loader',
      }
    ]
  },
  csso: {
    logger: function(stage, ast) {
      console.log(stage, ast);
    }
  }
};

License

MIT © Andrew Smirnov

Keywords

webpack

FAQs

Package last updated on 01 Apr 2020

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.