Gulp-sass : scss file not compiled + variables

2019-08-18 01:08发布

I'm new on using Gulp and gulp-sourcemaps for sass files. I encouter an issue when compiling scss file. So I finally think sourcemaps is the guilt because when I open the last created css.map file, I don't find mention of my last scss file modified and compiled.(but not if I disable sourcemap creation). In addition, path to scss files in firebug isn't the right one.This is my gulp task:

 var basePaths = {
        src: './sass/**/*.scss', // fichiers scss à surveiller
        dest:  './css/', // dossier à livrer
        node_modules: './node_modules/',
        gems:'/home/webmaster/vendor/bundle/gems/'
    };
var assetsPath = {
  gems: [
    basePaths.gems + 'susy-2.2.2/sass',
    basePaths.gems + 'breakpoint-2.7.1/stylesheets',

    basePaths.node_modules +  'typey/stylesheets'
  ],
   node_modules: [
       //Ajoutés avec les gems pour simplifier     

  ],
 };
    var bs_reload = browserSync.reload;
    gulp.task('sasscompil', function () {
        return gulp.src(basePaths.src)
                .pipe(plugins.sourcemaps.init()) // Start Sourcemaps
                .pipe(plugins.sass({
                    noCache: true,
                    bundleExec: true,
                  includePaths: [].concat(
                    assetsPath.gems,
                    assetsPath.node_modules,
                    folderPaths.styles.src
                    ),
                    sourceMap: true,
                    outputStyle: 'compressed'

                })
    //            .on('error', plugins.sass.logError)
                        //    .on('error', console.error.bind(console, 'SASS Error :'))
                        //Avec fonction anti-crash sur erreurs
                        .on('error', onError)
                        )

                  .on('error', function(err){
            displayError(err);
        })
                .pipe(plugins.sourcemaps.write('.'))//Pour créer le fichier css.map à coté du css
                .pipe(gulp.dest(basePaths.dest))
                .pipe(plugins.size({title:'Taille du fichier css'}))
                .pipe(plugins.notify({
                    title: "SASS Compilé - Fichier Map créé",
                    message: "Les fichiers SCSS sont compilés dans le dossier CSS",
                    onLast: true
                }))
                .pipe(bs_reload({stream: true}))// prompts a reload after compilation

        ;
    });

Actually, I test simple compilation, and the last file (using variables defined in another scss file) isn't added to the application.css compiled file. my complete gulpfile

thanks

1条回答
做个烂人
2楼-- · 2019-08-18 01:42

I fix my issue when I changed the path of partials scss files as indicate above. So @import "folder/myfile.scss" become @import "./folder/_myfile.scss" No compilation errors or missing variables anymore after differents tests.

So I think it's good this time.

查看更多
登录 后发表回答