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

Use scss in the <style> tag #118

Open
uitcode opened this issue Mar 5, 2020 · 5 comments
Open

Use scss in the <style> tag #118

uitcode opened this issue Mar 5, 2020 · 5 comments

Comments

@uitcode
Copy link

uitcode commented Mar 5, 2020

How can I use scss in style tags of .svelte files?

@kaisermann
Copy link
Member

@uitcode You need to configure your project's preprocess step: https://svelte.dev/docs#svelte_preprocess

There are some packages that can help you setting up scss to work with svelte:

@kulturbande
Copy link

kulturbande commented Sep 23, 2020

I know it is an aged issue, but I had a similar problem with Typescript and LESS. If you going to use 'svelte-preprocess' you have the possibility to this to support all common preprosseses:

const autoPreprocess =  require('svelte-preprocess');
...
module: {
    rules: [
      ...
      {
        test: /\.(html|svelte)$/,
        exclude: /node_modules/,
        use: {
          loader: 'svelte-loader',
          options: {
            preprocess: autoPreprocess(),
          },
        },
      },
  ...
  ]
}

@JohnnyFun
Copy link

I wonder if the svelte-loader should accept a string tell it how to import your svelte.config.js instead or whatever file you define your preprocessor in?

Looks like [email protected] doesn't pass over function values in options, so when I debug into svelte-loader autoPreprocess() just ends up with the what appears to be only the serializable values (i.e. defaultLanguages), but no markup, script, and style.

image

@JohnnyFun
Copy link

I added this to svelte-loader index.js:

if (options.svelteConfigFileLocation) {
	const svelteConfig = require(options.svelteConfigFileLocation)
	options.preprocess = svelteConfig.preprocess
}

Then modified my webpack to pass svelteConfigFileLocation: path.resolve('../svelte.config.js') instead of preprocess: autoPreprocess().

@mcuppi
Copy link

mcuppi commented Jun 6, 2022

@dummdidumm; The original question has been answered so I would recommend closing this issue. Based on the discussion here, it might be worth creating another issue focused on loading a configuration file (svelte.config.js).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants