0

I am using gulp npm package to bundle the scss files into one single scss file in angular 13. I am facing issues like,

Error: Can't find stylesheet to import. ╷ 1 │ @use '@angular/material' as mat;

Code:

gulp = require('gulp');
sass = require('gulp-sass')(require('sass'));
combine = require('gulp-scss-combine');
concat = require('gulp-concat');
browserSync = require('browser-sync').create();

// the default task
gulp.task('default', function () {
  return gulp.src('./lib/src/lib/theming/prebuilt/internal.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(concat('test-internal.scss'))
    .pipe(gulp.dest('./dist/lib/theming/'))
    .pipe(browserSync.reload({
      stream: true
    }))
});

In the internal.scss file there are lot imports there to other scss files. The ultimate goal is to process the internal.scss file and generate all the scss styles in one file that is (test-internal.scss).

Previously i had used scss-bundle and bundle-scss npm package but they are not working after angular 12 migration.

3
  • There's not a lot of info to go on, but it sounds like the SASS compiler can't find the @angular/material package. Try putting a tilde in front of the path: @use '~@angular/material'. This tells the compiler to look in node_modules. Are you using node-sass or Dart sass? Commented Jul 26, 2023 at 4:42
  • @jla the above code is in angular 13. so in angular 13 automatically the ~ will be removed when migration runs. Commented Jul 26, 2023 at 6:39
  • Interesting. I suppose you've tried putting a relative path to the angular package? eg @use '../../../../../node_modules/@angular/material/_index.scss' or whatever the path to the file should be. Your gulpfile looks fine to me. I'm not sure you need to use concat, but it's probably not causing any issues as the sass compiler runs first Commented Jul 27, 2023 at 1:17

0

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.