unable to import scss file as react module - css

I have a Dashboard.tsx file and Dashboard.scss file (I'm using vscode)
I'm trying to import the scss file like so: Import * as style from './Dashboard.scss'
but it can't find the module,
I tried also import style from './Dashboard.scss'
same error,
even tried renaming to Dashboard.module.scss which eliminated the problem but react code won't compile.

Don't import it as named. simply use import "./Dashboard.scss"; and It should work.

Related

Importing style file into Nextjs Component

Can I Import css files directly into a component in Nextjs and use the classnames directy without the default named import method.
I have a huge html project and I want to convert it into Nextjs, But the styles are conflicting when I import it in the _app.js file, and if I convert the style files into .module.css files and import with a name, then I have to manually change every where.
Is there anyway to solve this?

ReScript React how to import CSS files?

I am working on porting an existing React App to ReScript React, however I am running into a few issues. Namely I can't for the life of me figure out how to import CSS in ReScript, for example, In React to import Bootstrap all I would have to do is:
import 'bootstrap/dist/css/bootstrap.min.css';
However there is no corresponding way to do this in ReScript (to my knowledge), I tried doing:
#module("bootstrap/dist/css/bootstrap.min.css")
But it doesn't work. How can I import CSS files in ReScript React?
Use a %%raw expression to import CSS files within your ReScript / React component code:
// in a CommonJS setup
%%raw("require('./styles/main.css')")
// or with ES6
%%raw("import './styles/main.css'")
Reference - https://rescript-lang.org/docs/react/latest/styling

How to automatically add import in less from the react app

I have an app created using react-create-app tool and I use a style.less file in src/assets/less that is compiled automatically.
In my style.less I import the style I have in the various react components in my app. I like the idea to have every component with his own style.less in there.
The first problem is the reference I have to add or update in the src/assets/less/style.less, every time I add a component or I rename it or I move it. Is there any way I can get all the import automatically?
If your webpack.config.js is configured correctly, you should be able to import each components styles like:
import './style.less';

Vuetify webpack alias css

I'm using the vuetify webpack boilerplate (https://github.com/vuetifyjs/webpack) and I can't get the aliases in /build/webpack.base.conf.js to work for importing css (like import "~assets/css/mycss.css") even though it's working like a charm for js import (like import MyComponent from "components/MyComponent").
I tried several potential solutions I found, none seem to work...
Is this even possible?
Try to remove .css at the end.
Change
import "~assets/css/mycss.css"
to
import "~assets/css/mycss"
For more details, check this: https://github.com/webpack-contrib/sass-loader#imports

Possible to import scss when component is imported?

is there a mechanism in the react ecosystem to import sass files only when a component is loaded? For example, I may have the following structure:
client/
main.scss
routes.jsx
main.html
imports/
components/
componentA/
ComponentA.jsx
ComponentA.scss
componentB/
ComponentB.jsx
ComponentB.scss
Let's say ComponentA is used only in the public area while ComponentB is used only in the admin area. If I #import both component stylesheets into the main.scss file, the public will be downloading extra data they will never use. Is there any solution to this problem in the sass world?
Since you are using meteor this is what you can do, use import in your jsx file
In your ComponentA.jsx file use:
/imports/components/componentA/ComponentA.scss
If you want to get the scss file only if you are rendering the component, then you can do a require of this file in the render method instead of using import in the file.
Here is the link :
https://guide.meteor.com/build-tool.html#css-importing

Resources