🚀 Socket Launch Week 🚀 Day 1: Introducing .NET Support in Socket.Learn More

css-as-json-loader

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-as-json-loader

Webpack loader that loads CSS and emits it as JSON (conformant with PostCSS API)

0.2.2-wip.1
latest
Version published
Weekly downloads
5
66.67%
Maintainers
1
Weekly downloads
 
Created

css-as-json-loader

Dependency Status devDependency Status

Webpack loader that loads CSS and emits it as JSON

Installation

css-as-json-loader on NPM

Usage

Put css-as-json-loader in as a loader in webpack.config.js. This loader is best combined with json-loader, as this plugin itself does not output a valid javascript module.

// in webpack.config.js
...
loaders: [{
  test: /\.css$/,
  loader: 'json!css-as-json'
}]

Example

path/to/some.css

a, b {
  prop: value;
}
@media screen {
  a {
    prop: other-value;
  }
}

example.js

var css = require('path/to/some.css');

// or ES2015-style
import css from 'path/to/some.css';

//css is now equal to the following:
css == {
  type: 'root',
  origin: {
    source: 'path/to/some.css',

  },
  nodes: []
}

FAQs

Package last updated on 01 Mar 2016

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