Giter VIP home page Giter VIP logo

Comments (2)

mattcompiles avatar mattcompiles commented on June 9, 2024

Sorry, no way we can support this from our side. The issue is with CRA.

from css-modules-typescript-loader.

fourpastmidnight avatar fourpastmidnight commented on June 9, 2024

Use craco? Follow the directions at craco to set it up for use with your project. Then all you need to do is add the following in the craco.config.js file:

const { addAfterLoader, loaderByName, throwUnexpectedConfigError } = require('@craco/craco');

const throwError = message =>
  throwUnexpectedConfigError({
    packageName: 'craco',
    githubRepo: 'gsoft-inc/craco',
    message,
    githubIssueQuery: 'webpack'
  });

module.exports = {
  webpack: {
    configure: (webpackConfig) => {
      console.log('Adding css-modules-typescript-loader...');
      const cssModulesTypeScriptLoader = {
        loader: require.resolve('css-modules-typescript-loader')
      };
      const { isAdded } = addAfterLoader(webpackConfig, loaderByName('css-loader'), cssModulesTypeScriptLoader);
      if (!isAdded) {
          throwError('Failed to add the css-modules-typescript-loader!')
      }

      return webpackConfig;
    }
  }
};

The only issue I'm currently running into is that I'm using a mono-repo with Yarn and PnP and this module seems to be trying to overwrite *.css.d.ts files in the PnP cache, which are really Zip files and so are read-only, causing an error. I'm trying to understand if there's a way to have this loader exclude those files or restrict what it attempts to create a typings file for.

In my project, I'm using Semantic UI React, and in the main App.tsx file, I'm using import 'semantic-ui-css/semantic.min.css'. This CSS file is offered as a npm library. And because it's imported, this webpack loader is attempting to create a typings flise for it. I really don't want it to.

First, I'm not doing something like import semanticUIStyles from 'semantic-ui-css/semantic.min.css', where then I could use semanticUIStyles in my react components to access discrete style classes. I'm simply importing the CSS file so that CSS styles are applied to the elements.

from css-modules-typescript-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.