Skip to content
This repository was archived by the owner on Oct 30, 2020. It is now read-only.
This repository was archived by the owner on Oct 30, 2020. It is now read-only.

typings-for-css-modules-loader 2.0 is now available (fork) #94

@Obi-Dann

Description

@Obi-Dann

Hello everyone,

I forked typings-for-css-modules-loader, applied some of the pull requests, made it compatible with css-loader >= 1 and simplified configuration options. You're very welcome to try it and provide any feedback.
https://github.com/TeamSupercell/typings-for-css-modules-loader

There's a list of changes

Changes

  • Upgrade all dependencies and ensure the loader works with webpack>=4 and css-loader>=0.28.11
  • Remove babel build - make the loader compatible with Node 8+ without additional build steps.
  • Change the loader from being a drop-in replacement of css-loader to be used alongside css-loader.
  • Remove orderAlphabetically options - the output keys are sorted by default
  • Remove namedExport and camelCase options. Generated type definition files now have default export and can both export locals and support dashes in property names out of box. Example:
export interface IMyComponentScss {
  "some-class": string;
  someOtherClass: string;
  "some-class-sayWhat": string;
}

export const locals: IExampleCss;
export default locals;
  • Use the built-in webpack logger to report errors. Remove the silent options because it becomes redundant
  • Add a new formatter option to allow formatting the generated files with prettier. That should solve the eol issues and apply consistent code style with other files in the code base.

Upgrade guide:

  • Update webpack config
module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [
          "style-loader",
          {
            loader: "@teamsupercell/typings-for-css-modules-loader",
            options: {
              // pass all the options for `css-loader` to `css-loader`, eg.
-             namedExport: true
            }
          },
+         {
+           loader: "css-loader",
+           options: {
+             namedExport: true
+           }
+         },
        ]
      }
    ]
  }
};
  • ensure all the typescript files import styles as default
- import * as styles from './styles.css';
+ import styles from './styles.css';
  • add allowSyntheticDefaultImports TypeScript compiler option if there are type errors related to default imports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions