JSPM

minify-cssinjs-loader

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q35024F
  • License MIT

A webpack loader to minify your css-in-js.

Package Exports

  • minify-cssinjs-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (minify-cssinjs-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

minify-cssinjs-loader

Build Status npm npm

A webpack loader to minify your css-in-js.

Install

yarn add minify-cssinjs-loader # or npm i minify-cssinjs-loader

Why

before:

let cls1 = css`
  color: red;
  .cls1 {
  display: block;
  background: url('...') no-repeat;

  & > h2 {
    color: red;
    font-size: ${size}px;
  }
}
`

after:

let cls1 = css`color:red;.cls1{display:block;background:url('...') no-repeat;&>h2{color:red;font-size:${size}px;}}`

Usage

awesome-typescript-loader example:

module.exports = {

  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [{
          loader: "awesome-typescript-loader",
          options: {
            useTranspileModule: true,
            transpileOnly: true,
            declaration: false,
            instance: 'at-loader2'
          }
        }, {
          loader: 'minify-cssinjs-loader',
          options: {
            tagRules: ['css', 'injectGlobal', ],
          }
        }, {
          loader: "awesome-typescript-loader",
          options: {
            target: 'ESNEXT',
            declaration: !__DEV__,
            useTranspileModule: __DEV__,
            // jsx: 'preserve',
          },
        }, ],
      },
    ]
  }
}

babel-loader example:

module.exports = {

  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [{
          loader: "awesome-typescript-loader",
          options: {
            useTranspileModule: true,
            transpileOnly: true,
            declaration: false,
            instance: 'at-loader2'
          }
        }, {
          loader: 'minify-cssinjs-loader',
          options: {
            tagRules: [],,
          }
        }],
      },
    ]
  }
}

License

MIT