1.1.0 • Published 12 months ago

react-inline-css-module v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

react-inline-css-module

Auto transform CSS Module class name for React with Webpack or Vite.

Like babel-plugin-react-css-modules, but more easy to use.

  1. Support Webpack and Vite
  2. Support import multiple style files

Webpack Configuration

module.exports = {
  ...
  module: {
    rules: [
      {
        test: /\.(js|jsx|ts|tsx)$/,
        use: [
          // options are optional
          { loader: 'react-inline-css-module/dist/webpack-loader', options: { reactVariableName: 'React' } },

          // other loaders, eg babel-loader
          ...
        ]
      }
    ]
  }
  ...
}

Vite Configuration

const reactInlineCSSModulePlugin = require('react-inline-css-module/dist/vite-plugin').default

module.exports = {
  ...
  plugins: [
    reactInlineCSSModulePlugin({ reactVariableName: 'React' })    // options are optional
  ]
  ...
}

TypeScript Configuration

{
  "compilerOptions": {
    "types": ["react-inline-css-module/src/style-name"]
  }
}

App Code Example

app.module.css

.app {
  color: #777;
}

.info {
  color: green;
}

App.tsx

import './app.module.css'

function App() {
  return (
    <div styleName="app">
      <div>content</div>
      <div styleName="info">info</div>
    </div>
  )
}
1.1.0

12 months ago

1.0.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.3

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago