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

Add SASS_PATH instructions to Sass stylesheet docs #5917

Merged
merged 1 commit into from
Dec 4, 2018

Conversation

jayantbh
Copy link
Contributor

A bunch of issues popped up with people asking how to have SASS/SCSS imports the way the would expect normally.
Turns out node-sass supports the SASS_PATH variable that we can use. This PR adds that to the documentation.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@jayantbh
Copy link
Contributor Author

🤔 Hmm. Changing a markdown file shouldn't have broken any tests I suppose.

Copy link
Contributor

@iansu iansu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Just a few minor changes and I think it'll be ready to go.

@@ -30,6 +30,16 @@ This will allow you to do imports like
@import '~nprogress/nprogress'; // importing a css file from the nprogress node module
```

`node-sass` also supports the `SASS_PATH` variable.

To use imports relative to a path you specify, and from `node_modules` without adding the `~` prefix, you can add a `.env` or `.env.development` (and `.env.production`) file at the project root with the variable `SASS_PATH=node_modules:my_directory`. For more directories you can keep adding them to `SASS_PATH` like `path1:path2:path3` and so on.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just specify .env and then link to the docs on adding environment variables: https://github.com/facebook/create-react-app/blob/master/docusaurus/docs/adding-custom-environment-variables.md#adding-development-environment-variables-in-env.

Replace my_directory with src as it's probably the most common use case.

Change the last sentence to something like "To specify more directories you can add them to SASS_PATH separated by a : like so: path1:path2:path3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented this change.


To use imports relative to a path you specify, and from `node_modules` without adding the `~` prefix, you can add a `.env` or `.env.development` (and `.env.production`) file at the project root with the variable `SASS_PATH=node_modules:my_directory`. For more directories you can keep adding them to `SASS_PATH` like `path1:path2:path3` and so on.

Assuming you have `SASS_PATH=node_modules:src`, this will allow you to do imports like the way you’re used to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to "If you set SASS_PATH=node_modules:src this will allow you to do imports like"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented this change.

A bunch of issues popped up with people asking how to have SASS/SCSS imports the way the would expect normally.
Turns out `node-sass` supports the SASS_PATH variable that we can use. This PR adds that to the documentation.
@netlify
Copy link

netlify bot commented Dec 4, 2018

Deploy preview for gallant-davinci-8f9bd9 failed.

Built with commit ae4a949

https://app.netlify.com/sites/gallant-davinci-8f9bd9/deploys/5c06555de47085121a9f12a3

@iansu iansu added this to the 2.1.2 milestone Dec 4, 2018
@iansu iansu merged commit 013c8f2 into facebook:master Dec 4, 2018
@iansu
Copy link
Contributor

iansu commented Dec 4, 2018

Thanks!

@jayantbh jayantbh deleted the sass-path-docs branch December 5, 2018 11:35
timsnadden added a commit to timsnadden/create-react-app that referenced this pull request Dec 7, 2018
* master: (39 commits)
  Added extension to .eslintrc (facebook#5988)
  Update links to docs in all package README files (facebook#5912)
  Use https for linked images in docs to fix mixed content warnings (facebook#5985)
  Improve error messaging in verifyPackageTree.js (facebook#5974)
  Add removeItem to localStorage mock in docs (facebook#5919)
  Add SASS_PATH instructions to Sass docs (facebook#5917)
  Suggest a different default for speed reasons (facebook#5959)
  Add pre-eject message about new features in v2 (facebook#5954)
  Add netlify.toml to prepare for deploy to netlify facebook#5807 (facebook#5930)
  Correct some comments (facebook#5927)
  Add note to docs about using Sass and Flow together (facebook#5823)
  Update PWA link in README (facebook#5907)
  Add placeholders to template README for bit.ly links. (facebook#5808)
  Disable copy to clipboard in cra --info (facebook#5905)
  Support setupTests.ts (facebook#5698)
  Remove unnecessary whitespace in template HTML
  Run prettier on HTML files (facebook#5839)
  Some Grammar fixes (facebook#5858)
  Fix link to page about running tests (facebook#5883)
  fix: make typescriptformatter support 0.5 of fork checker (facebook#5879)
  ...
@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants