Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CSS modules for .module.css #87

Closed
egoist opened this issue Mar 17, 2018 · 4 comments
Closed

Enable CSS modules for .module.css #87

egoist opened this issue Mar 17, 2018 · 4 comments

Comments

@egoist
Copy link
Owner

egoist commented Mar 17, 2018

Automatically enable CSS modules for .module.css .module.styl .module.stylus .module.scss .module.sass .module.less

@daniele-zurico
Copy link

Hi there I know that modules have been implemented with scss but I'm not able to get it working:
"rollup-plugin-postcss": "^1.6.2",

Rollup.config.js:

plugins: [
    external(),
    postcss({
      modules: true
    }),

helloWorld.module.scss

and in the tsx file:

import * as React from 'react';
import styles from './helloWorld.module.scss';
[!] (rpt2 plugin) Error: /Users/daniele/Documents/Projects/capgemini-conception/react-library/src/helloWorld/HelloWorld.tsx(2,20): semantic error TS2307 Cannot find module './helloWorld.module.scss'.

Am I doing something wrong?

@mildfuzz
Copy link

Hi there I know that modules have been implemented with scss but I'm not able to get it working:
"rollup-plugin-postcss": "^1.6.2",

Rollup.config.js:

plugins: [
    external(),
    postcss({
      modules: true
    }),

helloWorld.module.scss

and in the tsx file:

import * as React from 'react';
import styles from './helloWorld.module.scss';
[!] (rpt2 plugin) Error: /Users/daniele/Documents/Projects/capgemini-conception/react-library/src/helloWorld/HelloWorld.tsx(2,20): semantic error TS2307 Cannot find module './helloWorld.module.scss'.

Am I doing something wrong?

Was this resolved? looking at the same issue...

@daniele-zurico
Copy link

Hi @mildfuzz yes I got it working correctly. This is my config:

const postcss = require('rollup-plugin-postcss');
module.exports = {
  rollup(config, options) {
    config.plugins.push(
      postcss({
        modules: true,
      })
    );
    return config;
  },
};

bung87 pushed a commit to bung87/rollup-plugin-postcss that referenced this issue Dec 3, 2019
@aravindsagar
Copy link

For anyone stumbling into this thread, this is not an issue with rollup-plugin-postcss. The error message says its coming from rpt2 (rollup-plugin-typescript2). This means that typescript does not know what to do with those imports.

To resolve this, simply add this to src/globals.d.ts as needed:

declare module "*.module.css";
declare module "*.module.scss";

You can also install typescript-plugin-css-modules for IDE support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants