0

I'm using angular 2 + webpack + scss. And by some reason I cannot use scss variable:

 $white: #fff;
.test{
 color: $white;
}

In style console I see that color is not set (strikeout).

My webpack config:

module: {
loaders: [
  { test: /\.ts$/, loader: 'ts-loader', exclude: /node_modules/ },
  {
    test: /\.scss$/,
    exclude: /node_modules/,
    loader: ['raw-loader', 'sass-loader']
  }
]

Does someone know what it could be?

8
  • No I just create a sample Commented Apr 26, 2016 at 12:34
  • Did you look at your compiled CSS? Commented Apr 26, 2016 at 12:35
  • { test: /^((?!materialize).)*\.css$/, loader: 'raw-loader' } Commented Apr 26, 2016 at 12:56
  • That can't seriously be your CSS, are you sure you're looking at the right file? Commented Apr 26, 2016 at 12:57
  • I'm have very bad imagination haw webpack do scss magic. I configure webpack as it provided there. And I don't have css file at all. Commented Apr 26, 2016 at 13:15

2 Answers 2

1

If the styles are crossed out in your browser, it means that scss is doing what it needs to do but other styles have a higher selector specificity for the same properties you are trying to change.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm not try to change anything. Just create scss variable and use it in test class.
0

You have a syntax bug in your webpack config. You have to use loaders not loader! See: https://webpack.github.io/docs/configuration.html#module-loaders

module: {
loaders: [
  { test: /\.ts$/, loader: 'ts-loader', exclude: /node_modules/ },
  {
    test: /\.scss$/,
    exclude: /node_modules/,
    loaders: ['raw-loader', 'sass-loader'] // loaders not loader
  }
]

6 Comments

How does this answer the question, exactly? Were you able to reproduce the OP's problem? How does this fix it?
The syntax of the webpack config ist wrong. See webpack.github.io/docs/configuration.html#module-loaders
So in other words, you should be voting to close this as a typographical error, yes?
Is there an option to close an question in case of a syntax error ?
Yes, "off-topic because..." > "This question was caused by a problem that can no longer be reproduced or a simple typographical error.". Its usually helpful if you also leave a comment pointing out where the typo is when you do this to help future voters see the error as well. (Do note that the OP has already made a mistake in posting their code with the question.)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.