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

Sass preprocessor and CSS modules not working #65

Open
tiagoporto opened this issue Nov 23, 2021 · 7 comments
Open

Sass preprocessor and CSS modules not working #65

tiagoporto opened this issue Nov 23, 2021 · 7 comments

Comments

@tiagoporto
Copy link

tiagoporto commented Nov 23, 2021

Hi @fwouts, thanks to refer to this library in fwouts/react-screenshot-test#34.

The styles from my component is not being used. My guess is that SASS and CSS modules is being ignored.

Is there some example to configure that?

I'm reading the documentation for vite and seems that CSS module and SASS is already supported.

https://vitejs.dev/guide/features.html#css-modules

I tryed

// viteshot.config.js
const playwrightShooter = require('viteshot/shooters/playwright')
const playwright = require('playwright')
const vite = require('vite')

module.exports = {
  framework: {
    type: 'react',
  },
  shooter: playwrightShooter(playwright.chromium),
  filePathPattern: '**/*.screenshot.@(js|jsx|tsx|vue|svelte)',
  vite: vite.UserConfig,
}

Thank you

@fwouts
Copy link
Owner

fwouts commented Nov 23, 2021

Hi @tiagoporto! Have you already seen the Global CSS section in https://viteshot.com/docs/config/css#global-css?

@tiagoporto
Copy link
Author

Hi @fwouts , yeap. It's not my case I dont have any Global CSS.

Giving a short example.

// Component.scss
.button {
  background: red,
}
import styles from 'Component.scss'

export const Component = () => {
  return <button className={styles.button}>Text</button>
}

Styles from Component.scss is not being applied

@fwouts
Copy link
Owner

fwouts commented Nov 24, 2021

Shouldn't the import be ./Component.scss?

@tiagoporto
Copy link
Author

Ohh sorry, yes.
It's an error in the example I shared.
The import is correct ./Component

@fwouts
Copy link
Owner

fwouts commented Nov 25, 2021

Just confirming is there also a syntax error in the SCSS example with the comma instead of semicolon? :)

.button {
  // background: red,
  background: red;
}

@tiagoporto
Copy link
Author

tiagoporto commented Nov 25, 2021

Hi @fwouts,
there is no syntax error.

Let me update the example, you could ignore the syntax because I'm sure that styles are working in the application.

// Component.module.scss
.button {
  background: red;
}
import styles from 'Component.module.scss'

export const Component = () => {
  return <button className={styles.button}>Text</button>
}

This is my component in the application, there is no global CSS, all the styles are in the Component.module.scss, using CSS modules and SASS.

Screen Shot 2021-11-25 at 10 12 38 AM

This is the screenshot

Screen Shot 2021-11-25 at 10 14 41 AM

I did a test removing SASS and CSS modules and everything works, but using SASS and CSS modules not.

@fwouts
Copy link
Owner

fwouts commented Dec 13, 2021

Hi @tiagoporto, I've been unable to reproduce this issue. I did just notice that your config uses vite: vite.UserConfig which I think might not work, you could either omit it or use vite: {}.

If you have a minimal repro to share, I'd appreciate it!

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

No branches or pull requests

2 participants