Socket
Book a DemoInstallSign in
Socket

jscss-loader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscss-loader

Webpack loader for [React Inline](https://github.com/martinandert/react-inline). Unlinke the original React Inline, this loader supports arbitrary JavaScript (or TypeScript) code.

0.0.6
latest
npmnpm
Version published
Maintainers
1
Created
Source

Webpack loader for React Inline. Unlinke the original React Inline, this loader supports arbitrary JavaScript (or TypeScript) code.

Use the ExtractPlugin to output all styles to an external CSS file.

We assume that the default export is the stylesheet:

// Foo.css.ts
import { width, height } from "./constants";
import { gray } from "./colors";

export default {
  container: {
    width,
    height,
  },

  title: {
    color: gray,
  },
};

The

// Foo.tsx
import jss from "./Foo.css.ts";

function Foo() {
  return (
    <div className={jss.container}>
      <h3 className={jss.title}>Hello JSS</h3>
    </div>
  );
}

CommonJS

JavaScript is not transpiled with Babel because Babel is too large a dependency to include in this library. Avoid writing JavaScript using ES6 features that NodeJS doesn't support yet.

const constants = require("./constants");
const colors = require("./colors");

module.exports = {
  container: {
    width: constants.width,
    height: constants.height,
  },

  title: {
    color: colors.gray,
  },
};

Webpack Configuration

const ExtractPlugin = require("jscss-loader").ExtractPlugin;

module.exports = {
  module: {
    loaders: [
      {
        test: /\.css.(ts|js)$/,
        loader: jssLoader,
      }
    ],
  },

  plugins: [
    new ExtractPlugin(),
  ],
}

Keywords

webpack

FAQs

Package last updated on 29 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

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.