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

[FEAT] add support for css modules #80

Open
abhijithvijayan opened this issue Nov 29, 2021 · 1 comment
Open

[FEAT] add support for css modules #80

abhijithvijayan opened this issue Nov 29, 2021 · 1 comment
Labels
effort: low around a day or less 💡 Proposed Work This is work that _might_ be worth doing, but that hasn't been started yet.

Comments

@abhijithvijayan
Copy link
Owner

abhijithvijayan commented Nov 29, 2021

adjusting webpack config like

		{
            loader: 'css-loader', // Takes the CSS files and returns the CSS with imports and url(...) for Webpack
            options: {
              sourceMap: true,
              modules: {
                localIdentName: isDevelopment
                  ? '[path][name]__[local]'
                  : '[hash:base64]',
              },
              importLoaders: 1,
            },
          },

will add support for css modules so that

import styles from './styles.scss';

export const Login: React.FC = () => {
  return (
    <section className={styles.login}>
      <h2>extension</h2>
    </section>
  );
};

will work fine

Screenshot 2021-11-29 at 11 19 00

@abhijithvijayan abhijithvijayan added effort: low around a day or less 💡 Proposed Work This is work that _might_ be worth doing, but that hasn't been started yet. labels Nov 29, 2021
@thehigherbounce
Copy link

If you wanna add SVG or CSS into component as a module, just need some changement.
Create a custom.d.ts file in root directory.

declare module '*.svg' {
    import * as React from 'react';

    export const ReactComponent: React.FunctionComponent<
        React.SVGProps<SVGSVGElement>
    >;

    const src: string;
    export default src;
}
declare module '*.css'
declare module '*.scss'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: low around a day or less 💡 Proposed Work This is work that _might_ be worth doing, but that hasn't been started yet.
Projects
None yet
Development

No branches or pull requests

2 participants