question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add scss import pattern to allow importing all css/scss files from folder

See original GitHub issue

Is your proposal related to a problem?

Since I’m using scss modules, I have a main scss file with some common rules that’s being imported in .jsx file. In this main scss file, I need to import all scss files from a folder. They work as template options: each imported scss is one specific template and it can grow over time, increasing the number of templates. Nowadays, I need to import every single file such like this:

mainTemplate.module.scss

// must import every single template
@import "./templates/template01.scss";
@import "./templates/template02.scss";
// ... some files later ...
@import "./templates/template20.scss";

Describe the solution you’d like

I’d like to achieve the same above with the following syntax:

mainTemplate.module.scss

// one single import ...
@import "./templates/*";
// ... and it's done!

Describe alternatives you’ve considered

I’ve found this Stack Overflow question: https://stackoverflow.com/questions/44646201/create-react-app-how-do-i-import-all-scss-files-from-a-directory/44646609#44646609 Wich refers to this npm package: https://www.npmjs.com/package/import-glob-loader

Additional context

Nothing to add

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:9
  • Comments:5

github_iconTop GitHub Comments

2reactions
mftbcommented, Sep 25, 2019

+1

Maybe this could be solved by adding import-glob-loader into CRA webpack.config file?

0reactions
Zephyr0402commented, Jul 20, 2020

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sass: @import
Sass extends CSS's @import rule with the ability to import Sass and CSS stylesheets, providing access to mixins, functions, and variables and combining ......
Read more >
How to import regular CSS file in SCSS file ? - GeeksforGeeks
In this article, we will learn how to import regular CSS files into SCSS files. Syntactically Awesome Style Sheet is the superset of...
Read more >
The New SASS Module System: Out with @import, In with @use
The new @use rule is the replacement for @import which allows other stylesheets to use its variables, functions, and mixins. What makes the...
Read more >
Is it possible to import a whole directory in sass using @import?
What I do to organize imports is adding an _all.scss file in a directory, where I import all the relevant files in it,...
Read more >
How to Set up SCSS in Your Web Projects | Code-Boost
SCSS allows for use of variables, nesting selectors, imports, mixins, and other features that are not yet available in CSS.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found