All Projects β†’ seek-oss β†’ Css Modules Typescript Loader

seek-oss / Css Modules Typescript Loader

Licence: mit
Webpack loader to create TypeScript declarations for CSS Modules

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Css Modules Typescript Loader

Sku
Front-end development toolkit
Stars: ✭ 403 (+134.3%)
Mutual labels:  webpack, front-end, css-modules
Front End Guide
πŸ“š Study guide and introduction to the modern front end stack.
Stars: ✭ 14,073 (+8081.98%)
Mutual labels:  webpack, front-end, css-modules
Braid Design System
Themeable design system for the SEEK Group
Stars: ✭ 888 (+416.28%)
Mutual labels:  webpack, front-end, css-modules
Seek Style Guide
Living style guide for SEEK, powered by React, webpack, CSS Modules and Less.
Stars: ✭ 302 (+75.58%)
Mutual labels:  webpack, front-end, css-modules
Css Modules Flow Types
Creates flow type definitions from CSS Modules files using Webpack loader or CLI πŸ‘Ύ
Stars: ✭ 92 (-46.51%)
Mutual labels:  webpack, webpack-loader, css-modules
Style Loader
Style Loader
Stars: ✭ 1,572 (+813.95%)
Mutual labels:  webpack, webpack-loader
React Boilerplate
React Boilerplate
Stars: ✭ 128 (-25.58%)
Mutual labels:  webpack, css-modules
Fe Interview
πŸ˜ƒ 每ζ—₯δΈ€ι“η»ε…Έε‰η«―ι’θ―•ι’˜οΌŒδΈ€θ΅·ε…±εŒζˆι•Ώγ€‚
Stars: ✭ 134 (-22.09%)
Mutual labels:  webpack, front-end
Svg Sprite Loader
Webpack loader for creating SVG sprites.
Stars: ✭ 1,822 (+959.3%)
Mutual labels:  webpack, webpack-loader
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-38.95%)
Mutual labels:  webpack, webpack-loader
React Pages Boilerplate
Deliver react + react-router application to gh-pages
Stars: ✭ 134 (-22.09%)
Mutual labels:  webpack, css-modules
Breko Hub
Babel React Koa Hot Universal Boilerplate
Stars: ✭ 145 (-15.7%)
Mutual labels:  webpack, css-modules
Universal React Redux
🧐 A sensible universal starter kit for React + Redux
Stars: ✭ 112 (-34.88%)
Mutual labels:  webpack, css-modules
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (-34.88%)
Mutual labels:  webpack, webpack-loader
Webpack.js.org
Repository for webpack documentation and more!
Stars: ✭ 2,049 (+1091.28%)
Mutual labels:  webpack, webpack-loader
Webpack Tools
β˜•οΈJust a simple webpack sample project.
Stars: ✭ 106 (-38.37%)
Mutual labels:  webpack, webpack-loader
Dev Toolkit
Universal Development Toolkit for Javascript People
Stars: ✭ 134 (-22.09%)
Mutual labels:  webpack, css-modules
Awesome Web You Should Know
🌎awesome web you should know
Stars: ✭ 154 (-10.47%)
Mutual labels:  webpack, front-end
File Loader
File Loader
Stars: ✭ 1,846 (+973.26%)
Mutual labels:  webpack, webpack-loader
Es Css Modules
PostCSS plugin that combines CSS Modules and ES Imports
Stars: ✭ 165 (-4.07%)
Mutual labels:  webpack, css-modules

Build Status npm semantic-release Commitizen friendly

css-modules-typescript-loader

Webpack loader to create TypeScript declarations for CSS Modules.

Emits TypeScript declaration files matching your CSS Modules in the same location as your source files, e.g. src/Component.css will generate src/Component.css.d.ts.

Why?

There are currently a lot of solutions to this problem. However, this package differs in the following ways:

  • Encourages generated TypeScript declarations to be checked into source control, which allows webpack and tsc commands to be run in parallel in CI.

  • Ensures committed TypeScript declarations are in sync with the code that generated them via the verify mode.

Usage

Place css-modules-typescript-loader directly after css-loader in your webpack config.

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'css-modules-typescript-loader',
          {
            loader: 'css-loader',
            options: {
              modules: true
            }
          }
        ]
      }
    ]
  }
};

Verify Mode

Since the TypeScript declarations are generated by webpack, they may potentially be out of date by the time you run tsc. To ensure your types are up to date, you can run the loader in verify mode, which is particularly useful in CI.

For example:

{
  loader: 'css-modules-typescript-loader',
  options: {
    mode: process.env.CI ? 'verify' : 'emit'
  }
}

Instead of emitting new TypeScript declarations, this will throw an error if a generated declaration doesn't match the committed one. This allows tsc and webpack to run in parallel in CI, if desired.

This workflow is similar to using the Prettier --list-different option.

With Thanks

This package borrows heavily from typings-for-css-modules-loader.

License

MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].