Gulp-sass : scss file not compiled + variables

我们两清 提交于 2019-12-25 09:45:37

问题


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:


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.



来源:https://stackoverflow.com/questions/44045467/gulp-sass-scss-file-not-compiled-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!