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

transpile Package SCSS/CSS Modules #41856

Closed
lewisvoncken opened this issue Oct 26, 2022 · 6 comments · Fixed by #42106
Closed

transpile Package SCSS/CSS Modules #41856

lewisvoncken opened this issue Oct 26, 2022 · 6 comments · Fixed by #42106
Assignees
Labels
area: app App directory (appDir: true)

Comments

@lewisvoncken
Copy link

lewisvoncken commented Oct 26, 2022

Describe the feature you'd like to request

to transpile scss modules in a monorepo you still have to use https://www.npmjs.com/package/next-transpile-modules

But the documentation indicates that the package is replaced

Describe the solution you'd like

Add support for scss transpile to the transpilePackage functionality
https://beta.nextjs.org/docs/api-reference/next.config.js#transpilepackages

Describe alternatives you've considered

update the docs that you still need next-transpile-modules for scss files

To use the appDir function it is required to remove next-transpile-modules

This results in this error

../../packages/ui/components/authSidebar/authSidebar.module.scss
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> .root {
|     --placeholder-style: 1;
| }
@lewisvoncken
Copy link
Author

as soon as you move the ui also to the transpilePackages option then scss modules are not allowed

../../packages/ui/components/authSidebar/authSidebar.module.scss
CSS Modules cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-modules-npm
Location: ../../packages/ui/components/authSidebar/authSidebar.js

@korsvanloon
Copy link

I tried both with css and scss and I can confirm both are not working for me either.

experimental: {
    appDir: true,
    transpilePackages: ['@acme/ui'],
  },

packages/ui/build/Carousel.js

...
import styles from './Carousel.module.css';
...
error - ../../packages/ui/build/Carousel.module.css
Module parse failed: Unexpected token (8:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| /*  GLOW */
| /*  RADIUS */
> .embla {
|   position: relative;
| }

@lewisvoncken
Copy link
Author

@balazsorban44
Do you have any tips in how I could solve this issue?

@TommySorensen
Copy link

TommySorensen commented Oct 27, 2022

I have the same issue. What is best practice here? Should the UI package from the monorepo export a build/dev step like NextJs suggested here https://nextjs.org/docs/messages/css-modules-npm ? Then how will the PostCSS compile the css files?

@balazsorban44 balazsorban44 changed the title transpile Package SCSS transpile Package SCSS/CSS Modules Oct 28, 2022
@taylorfsteele
Copy link

+1 on this. Feel free to check this stackblitz for a repro example: https://stackblitz.com/edit/node-rqan3w

ijjk added a commit that referenced this issue Oct 31, 2022
Fixes #41856. There is no way to apply those loader rules to specific
directories, especially when `transpileModules` is used. This PR changes
that to be based on the issuer layer.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants