Skip to content

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

License

Notifications You must be signed in to change notification settings

call-a3/css-as-json-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: []
}

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published