rits
rits

Reputation: 1544

Gulp not compiling sass although not showing any errors

SOLUTION:

Renaming _styles.scss to test.scss and _styles.css to test.css fixed it. Why?


It was working fine earlier. Now nothing is being compiled.The css files are not being created and are empty or not updated.

terminal:

asd@dsa:/var/www/html/mg/app/design/frontend/Training/default$ sudo gulp default
[sudo] password for asd: 
[14:50:48] Using gulpfile /var/www/html/mg/app/design/frontend/Training/default/gulpfile.js
[14:50:48] Starting 'default'...
[14:50:48] Finished 'default' after 14 ms
^C
asd@dsa:/var/www/html/mg/app/design/frontend/Training/default$ sudo gulp styles 
[14:50:56] Using gulpfile /var/www/html/mg/app/design/frontend/Training/default/gulpfile.js
[14:50:56] Starting 'styles'...
[14:50:56] Finished 'styles' after 13 ms
asd@dsa:/var/www/html/mg/app/design/frontend/Training/default$ sudo gulp pub
[14:51:02] Using gulpfile /var/www/html/mg/app/design/frontend/Training/default/gulpfile.js
[14:51:02] Starting 'pub'...
[14:51:02] Finished 'pub' after 12 ms

gulpfile.js:

var gulp = require('gulp');
var sass = require('gulp-sass');

gulp.task('styles', function() {
    gulp.src('web/sass/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('web/css/'));
});

gulp.task('pub', function() {
    gulp.src('web/sass/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('../../../../../pub/static/frontend/Scandi/default/en_US/css/'));
});

gulp.task('default', function() {
    gulp.watch('web/sass/**/*.scss',['styles']);
});

enter image description here

Upvotes: 2

Views: 466

Answers (1)

jacmoe
jacmoe

Reputation: 1687

Gulp-sass will happily compile everything that is not a Sass partial automatically whenever it changes.

By default, every Sass file that is prefixed with an underscore is a partial, and meant to be imported into one or more Sass 'master' files.

In practice, this means that you need at least one Sass file not prepended with an underscore for compilation to work/output properly.

In your case, simply rename _styles.scss to styles.scss and that should result in a styles.css in your target CSS directory. :)

Partials allows you to organize your Sass source code in very neat ways, see The Sass Way - How to structure a Sass project

Upvotes: 2

Related Questions