preboot / angular-webpack

A complete, yet simple, starter for Angular v2+ using webpack
MIT License
1.29k stars 556 forks source link

How to include scss? #308

Open biapar opened 7 years ago

biapar commented 7 years ago

How to include scss?

atul221282 commented 7 years ago

create scss file and use import or require statement, depending upon if ur using typescript or javascript, in main.ts file. For example if I have create main.scss the in main.ts file I would do import "main.scss";. This will put in head as style tag

shoagraw commented 7 years ago

I am also not able to compile scss to external file and loading from relative url I am checking the web.config.js and these four rules are confusing me:- // Support for CSS as raw text // use 'null' loader in test mode (https://github.com/webpack/null-loader) // all css in src/style will be bundled in an external css file { test: /.css$/, exclude: root('src', 'app'), loader: isTest ? 'null-loader' : ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader', 'postcss-loader']}) },

  // all css required in src/app files will be merged in js files
  {test: /\.css$/, include: root('src', 'app'), loader: 'raw-loader!postcss-loader'},

  // support for .scss files
  // use 'null' loader in test mode (https://github.com/webpack/null-loader)
  // all css in src/style will be bundled in an external css file
  {
    test: /\.(scss|sass)$/,
    exclude: root('src', 'app'),
    loader: isTest ? 'null-loader' : ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader', 'postcss-loader', 'sass-loader']})
  },
  // all css required in src/app files will be merged in js files
  {test: /\.(scss|sass)$/, exclude: root('src', 'style'), loader: 'raw-loader!postcss-loader!sass-loader'},

Just thinking there should be something to change these to start this happening.

samfrach commented 7 years ago

what is your exact problem ?

I have no problem working with that project and scss. I have also added the sass-resources-loader in order to avoid putting to many repeated "import" in my scss files.