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

next-css-json-loader

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-css-json-loader

transforms .css files into js modules that export style rules as json

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by75%
Maintainers
2
Weekly downloads
 
Created
Source

next-css-json-loader

NPM version Downloads Build Status Dependency status Dev Dependency status Coverage Status

Installation

$ npm install --save-dev next-css-json-loader

Setup

First you will need to create a next.config.js file:

module.exports = {
  webpack: config => {
    config.module.rules.push({
      test: /\.css$/,
      loader: 'emit-file-loader',
      options: {
        name: 'dist/[path][name].[ext]',
      }
    }, {
      test: /\.css$/,
      loader: 'babel-loader!next-css-json-loader',
    });
    return config;
  },
};

Usage

After setting the project, you may import CSS files like so:

// .css files now conveniently expose all styles as js objects
import styles, {
  rule,
  media,
  keyframes,
  fontFace,
  charset,
  raw
} from 'some-package/foo.css';

// If you are using glamor, you can easily generate styles like so
import { css } from 'glamor';
const className = css(styles);

// Don't forget any custom fonts or animations :)
const fonts = fontFace.map(x => css.fontFace(x));
const animations = keyframes.reduce((a, [name, timeline]) => {
  a[name] = css.keyframe(timeline);
  return a;
}, {});

Shout out to next-style-loader for inspiration!

License

MIT License

FAQs

Package last updated on 01 Mar 2017

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