We need to support a CSS compiler - Sass and Less. If CSS compilers are not supported on Stack Overflow code snippet which must be included. If it can't be supported in stack code snippets, allow users to include jsFiddle links.
-
7You are allowed to use JSFiddle links for such things, but you must also include all code from your JSFiddle in the question itself, in regular code blocks.– user247702Commented Nov 18, 2016 at 12:16
-
Ok, Thats good, Needs to refer this as a message along with the error while posting a question with a jsFiddle Link will be more good. :)– aspCommented Nov 18, 2016 at 12:29
-
1It should give you an error message like this one, does it not appear for you?– user247702Commented Nov 18, 2016 at 12:38
-
2Don't know Sass, but Less has a client-side solution: Is it possible to inline LESS stylesheets?, which could theoretically work in snippets.– Heretic MonkeyCommented Nov 18, 2016 at 14:45
-
Not only CSS transpilers like Sass and Less must be added but also JS transpilers for Typescript, Babel, Coffeescript and HTML transpilers for Pug and Markdown.– H. PauwelynCommented Mar 25, 2017 at 12:15
-
@MikeMcCaughan Sass is a server-side solution.– H. PauwelynCommented Mar 25, 2017 at 12:17
-
4My favorite thing about preprocessors and other languages that compile to HTML/CSS is how dependent authors have become on them. I'm glad I don't use any of them.– BoltClockCommented Jul 2, 2017 at 4:36
2 Answers
tl;dr: There is no valid and correct use case for using SASS in a Stack Snippet, it can only cause harm and encourages submitting questions that by definition do not include an MCVE. As a SASS developer, you need to know how SASS compiles to CSS, and how CSS applies to HTML. There are plenty of on-topic questions about SASS and CSS, or about CSS and HTML, but a question about SASS and HTML fundamentally makes no sense, because these two technologies cannot interact directly. Such a question has failed to be reduced to its simplest, minimal form.
Stack Overflow is not for hosting and iterating on large complex examples, the kind where SASS is really useful, and the kind that JSFiddle helps you produce. The purpose of Stack Overflow's snippets is to host minimal reproducible examples to support your question, not to host large complicated examples that allow groups to iteratively work on them.
JSFiddle also supports HAML instead of HTML, a dozen types of transpiled JavaScript, and many types of CSS preprocessor. If your question involves a web browser, every one of these higher level languages that transpile down to JavaScript/CSS/HTML adds a layer of complexity that is inappropriate for a MCVE. By definition, if your question is about browsers rendering pages, and your question includes SASS, you haven't done the work of producing a proper MCVE.
If your question is about SASS, then it should include SASS code. It should also include the compiled CSS generated at the time you asked your question, as the output is subject to change across versions of SASS. Using a version of snippets that supported SASS in this case would be incorrect: The output generated by Snippets could be the result of a bug that would go away when the SASS compiler is upgraded, rendering your question nonsensical. If you're asking about SASS, your question should be about the CSS it produces, or flags to the SASS compiler itself, or errors in SASS syntax, and snippets are of no use. You need to include the SASS and corresponding CSS or a specific error message.
On the other hand, if your question is about the way HTML, CSS and JavaScript interact in a browser at runtime, then your question's MCVE should include HTML, CSS, and JavaScript, nothing else. The browser doesn't "see" SASS, any more than it sees TypeScript or HAML. These are sources of complexity that by definition should not exist in an MCVE. In this case, forbidding SASS is a feature that produces better MCVEs. Including SASS would only require readers to manually compile the SASS to CSS to see what is actually running in the browser in order to diagnose the problem, a step that OP should have already taken in producing a MCVE.
In every hypothetical question that includes a Stack Snippet with SASS, one of the following is true:
- The SASS->CSS conversion is the problem: The answer points out a flaw in OP's understanding of how SASS compiles to CSS, and the CSS OP expected was not actually being produced. The solution is to fix the SASS so the correct CSS is produced; the HTML was irrelevant and did not need to be included. No Stack Snippet was actually necessary here, and allowing a Stack Snippet with SASS and HTML was harmful and obscured the problem. OP should have included SASS and asked why it didn't produce some specific CSS, or some specific CSS and asked why their SASS didn't produce it.
Or
- The CSS->HTML application is the problem: The answer is about how CSS failed to match or style the included markup; The SASS produced the expected CSS but OP's understanding of how that CSS interacted with HTML was incorrect. OP's question was actually a CSS question and SASS-enabled Stack Snippets was again harmful and obscured the actual problem. OP should have included CSS and HTML in a snippet, and asked why the CSS didn't behave as expected, or how to select the relevant HTML with CSS.
In both cases, SASS-enabled Snippets caused more harm than good. And in both cases, forcing OP to try to produce a CSS/HTML MCVE from their SASS likely would have prompted them to discover their actual problem ("my SASS isn't compiling as expected" or "my CSS isn't working as expected") and potentially allowed them to find the relevant solution without asking a question at all.
The code snippets feature doesn't work for >80% of the code posted on Stack Overlow. Why make the extra effort for the ~15,000 less and sass questions? Are web developers that special?
In fact, if your SASS or LESS snippet cannot be trivially converted to plain CSS then it's a good chance it's not really a MCVE and should probably be trimmed. It's also trivial to convert it yourself. Both LESS and SASS come with easy to use commandline tools and many online tools.
While I don't necessarily disagree that it would be a useful feature as such, the effort to benefit ratio is quite low. It's simply not worth the effort IMHO.
-
5
-
2If the reason for creating StackOverflow snippets was to remove the need to add links to JSFiddle, then why not also implement this feature of JSFiddle? Commented Apr 18, 2018 at 0:11