-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Optional Sass support - Part 2 #2498
Comments
@BrodaNoel CRA added SASS support a while ago if that's what you are asking for. |
Nop. That's support for pre-processors (from Sass to Css), and then You have to include the CSS file, instead of the .scss.
I'm asking if we can add the Sass loader to our Webpack config, so then will not be necessary to do those changes in package.json, or install new dependencies (as you can read in that doc you shared)
… El 8 jun 2017, a las 02:45, Cristian Rosescu ***@***.***> escribió:
CRA has been providing SASS support for a while now
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'm with you now. I agree that being able to import |
Absolutely! I have the same problem with |
need for Less support too if you want to use |
So someone is trying find solution for this issue? Is it worth waiting for the support of scss? |
@BrodaNoel @ruler47 Might be a workaround to get you what you need for now. |
@ruler47 I'd like to note that it is not required to eject to use Sass. Please read the following guide. |
I'm open to supporting Sass but only if people not using it don't have to get These use cases call for a plugin system but I don't think we're ready to support a whole addon ecosystem that's one step removed from webpack. So this is where it breaks down a little. Suggestions? |
configComposer from #2449? 😜 *presed comment prematurely. I'm thinking about https://github.com/webpack-contrib/npm-install-webpack-plugin |
Another concern is that I want config to be simple for people who eject. I don't want Sass to be there if they don't use it, but I also don't want Sass users to end up with an abstraction there. |
It's still configurable (with the same webpack API) if we place the resolvers in the config folder though. Just that it's in another place with resolving and installing logic. Like you said, it's still one step removed from regular webpack configuration object. |
When can we expect a solution for this to come out? Because this is a blocker for me and I can not find suitable replacement for CRA that is actually maintained. |
why don't you add an option for adding sass/less to the project when create a new project like: This was used similarly in angular-cli project, link here |
I can't think of any major production project that doesn't use SASS or LESS. It doesn't make sense why this wouldn't be included in a solution designed to help development into production.. |
For anyone else struggling to understand why sass isn't support out of the box and trying to add it - you can add support using module.exports = function override (config, env) {
config.module.rules[1].oneOf.splice(config.module.rules[1].oneOf.length - 1, 0,
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
},
)
// console.dir(config, { depth: 10, colors: true })
return config
} With that you can import sass with just You'll need |
Here's my proposal for how we can include Sass without compromising on user experience for people who don't want it: webpack-contrib/sass-loader#532 |
If webpack-contrib/sass-loader#533 gets in we have a relatively neat way of doing this. In that case the next action item here would be to ask for an alpha of |
I have some stuff in my backpack. I was forced to add I was testing my project via:
Neither did work. After adding I see an issue that developer might not want to use Sass in the project, while he or she will get a redundant dependency. I created these commits from https://github.com/miraage/create-react-app/commit/751d15ed59a7e7a9ba29bc5b6c9bdd98a5e3444d https://github.com/miraage/create-react-app/commit/4aebe2349514fee9c75ea85fbea31ea271b73dc9 |
I tried to quickly put something together: aurelienshz@8d679a4, based on the work done by @miraage. I feel like this could be worth exploring in case webpack-contrib/sass-loader#533 doesn't make it, or in any other situation where an opt-in loader is needed. The idea is pretty much the same as what @gaearon described in webpack-contrib/sass-loader#532, but using a custom wrapper around sass-loader. I'm not really sure how reliable this would be, and it also probably implies a performance hit, but the main idea is there. Suggestions welcome! 🙂 |
I tried the solution proposed by @samuelcolvin and the sourceMap does not seem to show the actual SCSS file where the styles originate. I also tried the
Working with SASS without a sourcemap solution is far less efficient from my experience. I'm enthusiastic for an opt-in solution that might include a working sourcemap solution without ejecting. |
Unnecessarily hyperbolic, sass without source maps isn't perfectly but it's completely usable. |
@samuelcolvin Sincere apologies. I went ahead and updated the comment. Super appreciative of this project and all the work that everyone has done here. |
Seems like what Next.js has implemented: https://github.com/zeit/next-plugins/tree/master/packages/next-sass#usage Thanks for the effort to bring this to CRA, the current workflow is really confusing and I find myself often editing the |
Hide the .css file in your text editor, for the current proyect.
… El 13 feb 2018, a las 03:57, franciscop-invast ***@***.***> escribió:
Seems like what Next.js has implemented: https://github.com/zeit/next-plugins/tree/master/packages/next-sass#usage
Thanks for the effort to bring this to CRA, the current workflow is really confusing and I find myself often editing the .css just to realize there was a .scss on its side.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@gaearon If sass/scss support is added to create-react-app, I'd recommend taking a page from rails/webpacker and check for |
For the record, I've been discussing with the contributors of CRA and I'm preparing a PR for that atm! |
Sass support is coming. I'll close this, but it'll be released in 2.0. There's an open PR now! |
As I just read in #78,
CRA
don't want to add support to Sass and Less.Then, I read Dan saying:
So, what's the state of this?
I few hours ago I implemented Sass and Less in a personal project out of
CRA
.I just added a new rule in webpack modules, and a couple of dependencies and Gualá!
Following this example, we should do not deal too much with this implementation: https://github.com/webpack-contrib/sass-loader#examples
Something really nice in those loaders is that it's not necessary to convert Sass to CSS explicitly.
So,
as all loaders do, just including the.scss
file is enough.I read tons of times that you repeat the same question: "Why you guess Sass is necessary in React?". Well, in my case, I don't use Sass to reutilize CSS. I use Sass to write CSS as a tree, and it's useful to define vars that are useful to create a template structure in the site/component.
My best example (tree view, vars, cals, and imports that can be used to define the whole site styling):
If you think it's time to add Sass, I can create a PR with those chances (or, at least, I'll try).
If not, ok.
Thank you!
The text was updated successfully, but these errors were encountered: