Skip to content

Instantly share code, notes, and snippets.

@SeyyedKhandon
Last active May 19, 2021 11:35
Show Gist options
  • Save SeyyedKhandon/1b8ec61f64620f78df2ebf88b89b720c to your computer and use it in GitHub Desktop.
Save SeyyedKhandon/1b8ec61f64620f78df2ebf88b89b720c to your computer and use it in GitHub Desktop.
import variable.scss everywhere using craco
  1. yarn add @craco/craco --dev

  2. create craco.config.js at the root of your project, and put these in it

module.exports = {
  reactScriptsVersion: 'react-scripts',
  style: {
    sass: {
      loaderOptions: {
        additionalData: `@import "src/assets/styles/variables/index.scss";`
      }
    }
  }
}; 
  1. update scripts in the package.json
/* package.json */

"scripts": {
-   "start": "react-scripts start",
+   "start": "craco start",
-   "build": "react-scripts build",
+   "build": "craco build"
-   "test": "react-scripts test",
+   "test": "craco test"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment