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

Codesandbox doesn't work with Bootstrap SCSS imports #4865

Closed
3 tasks done
gragland opened this issue Sep 8, 2020 · 9 comments · Fixed by #5876 or #5879
Closed
3 tasks done

Codesandbox doesn't work with Bootstrap SCSS imports #4865

gragland opened this issue Sep 8, 2020 · 9 comments · Fixed by #5876 or #5879
Assignees
Labels
🐛 Bug 🎒 Bundler Refers to CodeSandbox's In-Browser Bundler

Comments

@gragland
Copy link

gragland commented Sep 8, 2020

🐛 bug report

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Description of the problem

CodeSandbox displays the following error when trying to hot load changes to a .scss file that imports Bootstrap: Cannot find module 'bootstrap/scss/mixins' from '/src'. The initial transpilation works fine, so it seems to just be an issue with how hot loading handles imports.

I believe the issue is that Bootstrap has both a file named _mixins.scss and a directory named mixins. The initial transpilation properly imports _mixins.scss with the syntax @import "mixins";. My best guess is that subsequent hot loading either attempts to import the mixins directory instead or it's having issues with the underscore prefix in _mixins.scss and it's not finding it.

This affects Bootstrap and presumably other CSS frameworks that have this file/folder structure.

To Reproduce

  1. Visit this Codesandbox: https://codesandbox.io/s/codesandbox-scss-bug-37op3?file=/src/styles.scss
  2. Wait for the initial transpilation then modify the primary color SCSS variable to any other color.
  3. You'll see the error Cannot find module 'bootstrap/scss/mixins' from '/src'
  4. Refresh and you'll notice your change takes affect (initial transpilation works, just an issue with hot loading)

Further Thoughts

I noticed there was previously a fix (#529) for SASS resolving underscores incorrectly. Maybe this fix isn't present in the hot loading logic?

Link to sandbox: link

Your Environment

Software Name/Version
Сodesandbox 40d7518
Browser Chrome 84.0.4147.125
Operating System macOS 10.15.6
@christianalfoni
Copy link
Contributor

Hi @gragland and thanks for reporting a detailed issue!

We have looked at it and identified the issue, though we have a long list of prioritized issues, so just need "to get there". Sorry for the wait, but it will be fixed eventually!

@gragland
Copy link
Author

gragland commented Dec 1, 2020

Just wanted to check in and see if this is on the priority list. This has been causing issues for Divjoy customers who use our "Export to CodeSandbox" feature. If it looks like this is pretty far out on the roadmap (which I totally understand) then I'll need to disable the feature for now.

@SaraVieira
Copy link
Contributor

Hey

I tried to take a look at this today and still do not understand why this happens, the reload logic is the same as the build logic for the first time :/

Will keep digging tommorrow

@virtualbis
Copy link

Seems I have similar issue when using Sass partials. I have posted a question here on stackoverflow but it seems to be a bug.

When I use @import "./_home"; it works fine but I originally had, as per Sass documentation, @import "./home"; which should work as well. Please confirm this is a bug or if I am doing something wrong here.

@github-actions
Copy link

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

@github-actions github-actions bot added the stale label Apr 24, 2021
@gragland
Copy link
Author

This appears to still be an issue (commenting so not auto closed)

@github-actions github-actions bot removed the stale label Apr 25, 2021
@lbogdan lbogdan added 🎒 Bundler Refers to CodeSandbox's In-Browser Bundler 🐛 Bug labels May 25, 2021
@DeMoorJasper DeMoorJasper mentioned this issue Jun 7, 2021
4 tasks
@gragland
Copy link
Author

gragland commented Jun 4, 2022

This problem appears to be back.

Seems like hot loading isn't properly handling nested sass imports so variables are undefined.

@vdeantoni
Copy link

Can we please reopen this issue?

@symmetriq
Copy link

Just encountered this now. The following error shows up every time a hot reload occurs:

Undefined variable.
  ╷
6 │ $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default;

Manually reloading the preview makes it work…once…but it will fail again after the next hot reload.

Simple repro:
https://codesandbox.io/s/flamboyant-kowalevski-zlfn5i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug 🎒 Bundler Refers to CodeSandbox's In-Browser Bundler
Projects
None yet
9 participants