Assuming you have successfully installed
node-sass in a TypeScript
create-react-app React application, just as you would Add/import a CSS stylesheet by doing the following:
For a SCSS stylesheet, you would simply change the file type:
In your example you simple need to treat it as a Import a module for its side effects only instead of a default import like you are currently attempting.
You can also treat it as a SCSS Module by updating the SCSS filename to
mystyles.module.scss and importing it as follows:
import styles as './mystyles.module.scss';
I was able to achieve both bits of functionality doing the following as Sass/SCSS support is built in by default in
email@example.com and higher projects:
- Created a TypeScript create-react-app using command
npx create-react-app my-app --template typescript
- Navigated into the create
directory and install node-sass using command
npm install --save node-sass
- Changed default generated
- Changed import in
Make sure you have
node-sass installed. If that doesn't help, you may need to revisit how you created/converted your
create-react-app to be in TypeScript.
You need to either import it as
import './mystyles.scss'; or actually put
module in the file name and import it as
import whatever from './mystyles.module.scss';.
- How to use React with Typescript and SASS
- How to use emotion/styled with React and Typescript
- How to use mixins with Typescript and React JSX (TSX)
- How to use Typescript with React Router and match
- how to use Sass variables and mixins with react js
- How to use refs in React with Typescript
- How to use TypeScript with withRouter, connect, React.Component and custom properties?
- How to use vw and vh css with React Native
- How to use forwardRef with FunctionComponent in React Native using TypeScript
- How to use Material UI custom theme in React with Typescript
- how to use .env file in a react js with typescript project?
- How to use jest.spyOn with React function component using Typescript
- React Typescript how send props and use it in child component
- How to use Django User Groups and Permissions on a React Frontend with Django Rest Framework
- How do you correctly use React.lazy() in Typescript to import a react component with a generic type parameter?
- How to use HOC with redux compose and Typescript
- How to use Jest with React and Webpack
- How to use srcset 2x with React and Webpack?
- React how to use icon inside Textfield Material-UI with TypeScript
- How to use Refs with Material-ui 4, React 16.8, TypeScript 3.5
- How to use inheritance with React components and es6 classes
- Use onFocus on a div with React and Typescript
- How to test with jest and typescript with types a basic react function component
- How to use Material UI custom variants in React with Typescript
- How to use radium in React typescript (Error: has no properties in common with type 'CSSProperties'. TS2559)?
- How to use React Hook Form with Typescript (Input Component)
- How to use setTimeout() along with React Hooks useEffect and setState?
- How to Use SVG with React and ReasonML?
- How to use Sass and CSS Modules with create-react-app?
More Query from same tag
- Introducing errors when refactoring within <Route /> in React front end
- How to Refactor an Async Function out of a React Component
- React JS setState for an array
- How to load a <div> on top of React google map component?
- react-quill custom save button to firebase
- route.params never updates react navigation v5
- how can I use async data from node api?
- Empty Mime-type while uploading file in React js application in Windows OS
- How to access a child's state in React
- How to give a custom id to a heading in markdown?
- Mapping from two different data sources
- React Call back Function
- Methods of matching string input with numerical input in ReactJS?
- How to fetch from API using useReducer and useEffect while still allowing requery
- how to fetch props data within double quotes in rectjs
- Where to put component did mount in my next.js file
- Loading Image in a React+Django app
- Test Functions Passed as Props to Component
- get index from click and set class to same index in another container in react component
- Best way to sharing function in react
- "SyntaxError: Unexpected token < in JSON at position 0"
- Downsample the audio from buffer inputs from 48000 to 16000
- How to style Material UI's Tab component label?
- Enzyme Click on Button Inside Component Inside Component
- ReactJS: fakepath issue in repeater
- How to expand all Panels in Antd Collapse without specifying every single tab key as activeKey
- In React how can I set state variables in a loop?
- TypeError: this.state.workorders.map is not a function
- React/Redux URL mismatch: When the array item number differs from the object id
- react-hook useFormInput() form validation not working