-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Global SCSS variables #232
Comments
Does the error occur only when using global variables, or always? If always, did you follow the instructions for SCSS? Especially the last point (setting node path) might be what you need to do. |
Really dunno what to do. Any idea? |
Need something like global reference to variables, so extension will know about it + autocompleting. |
You need to have the same preprocessor config setup in your |
Restarted lang-server, restarted vscode, nothing changed, still warning in componen. |
@daarxwalker - IIRC includePaths does not by definition make the variables available within all your SCSS code. It just provides SCSS specific paths from which imports can be resolved - e.g. to avoid having to hard-code full paths. So for example you might include 'node_modules' if you know you have dependencies there... So I think you still need an @import for your dependencies inside your component <style> tag. I don't have time to confirm in docs yet; but that's what I'd check first ;) |
I know. I tried without data and import, still same message. But it's really pretty bad, if I can't just inject variables to all components in one place. I can live with @import 'theme'; in all components, but it still doesn't work. |
If your build runs fine, this is "just" an IDE intellisense error which we have to fix. So you can continue programming and ignore the error until we have come up with a solution. |
I know, i know. But it's really annoying and I don't know, if I don't have to do something more in configs. Thanks anyway for guides. |
I cannot reproduce this. This is what I did:
import autoPreprocess from 'svelte-preprocess';
export const preprocess = autoPreprocess({
includePaths: ['src'],
});
|
Narrow down in which step the error occurs and try to extract better error messages. sveltejs#86, sveltejs#232, sveltejs#129
You cannot use the new syntax inside the const autoPreprocess = require('svelte-preprocess');
module.exports = {
preprocess: autoPreprocess({
scss: { includePaths: ['src/styles'], data: '@import "theme";' },
postcss: { plugins: [require('autoprefixer')] }
}),
}; This worked for me. |
You still don't have an |
@dummdidumm You're right about svelte.config.js, warning disappear. What about autocomplete, still not working. Really need to have manual @blindfish3 I know. I want it global. It's standard thing with SCSS. |
Since the error went away I'm going to close this. Autocomplete is not supported yet, please open another feature request for this. |
This worked for me: svelte.config.js
rollup.config.js
App.svelte
If you want the errors in terminal to go away on rollup.config.js
The coolest thing is my main.scss file can import partials.
Documentation here: https://github.com/sveltejs/svelte-preprocess/blob/main/docs/getting-started.md |
Hey guys,
have a one little problem. I tried to have global SCSS variables. Compilation works, but extension seems not. I get it, when importing nothing, it doesn't know about variables.
I added this to rollup.config.js as argument to autoPreprocess():
In svelte.config.js doesn't work, so that's why rollup.config.js.
I have file _theme.scss in included path, as I said, compilation works.
But when I use variables like this:
..it shows at the beggining of component this
The text was updated successfully, but these errors were encountered: