Git Product home page Git Product logo

Comments (6)

mikevercoelen avatar mikevercoelen commented on September 26, 2024

@gangsthub Hi thanks for asking a question and so making the plugin better.

I have looked into it and you are totally right, this is not the expected behavior.

I'm going to dive into the code asap. For now I hope you came up with a temporary solution. I keep you posted.

Thanks

from gulp-sass-glob.

gangsthub avatar gangsthub commented on September 26, 2024

Sorry for the typos, and thanks to you, Mike

from gulp-sass-glob.

webegguk avatar webegguk commented on September 26, 2024

ignorePaths would be really helpful for a project I'm developing that requires different sets of css for different sites which all share the same library of sass. This doesn't work for me either so a big +1 from me on this. Again, great plugin other than this.

My pipe looks like this:

return gulp.src('./theme/sass/**/*.{scss,sass}')
    // Initializes sourcemaps
        .pipe($.sourcemaps.init())
        .pipe($.sassGlob({
            ignorePaths: [
                './theme/sass/**/brand-one.scss', // not working
                './theme/sass/**/brand-two.scss' // not working etc
            ]
        }))

from gulp-sass-glob.

mikevercoelen avatar mikevercoelen commented on September 26, 2024

@webegguk @gangsthub Could you take a look at the code and see if you guys can help me with creating a PR for this feature?

Is it still relevant? Give me a bump so I can take a look at it ;)

from gulp-sass-glob.

paymok avatar paymok commented on September 26, 2024

@mikevercoelen I also come across with this problem and try to dig into the code, the issue is seems related to minimatch library you are using.

For example, if I am compiling the sass in a windows environment,

main.scss

// I want to include all scss files in the project but expect to ignore plugin's scss in the pipe 
@import "../../folder/app/**/*.scss";

pipe

    // Initializes sourcemaps
        .pipe($.sourcemaps.init())
        .pipe($.sassGlob({
            ignorePaths: [
                '**/plugins/**/*.scss'
            ]
        }))

This will not work because in inside the path matching logic

files.forEach(function (filename) {
          if (filename !== file.path && isSassOrScss(filename)) {
            // remove parent base path
            filename = _path2.default.normalize(filename).replace(basePath, '');
            if (!ignorePaths.some(function (ignorePath) {
              return (0, _minimatch2.default)(filename, ignorePath);
            })) {
              // remove parent base path
              imports.push('@import "' + (0, _slash2.default)(filename) + '"' + (isSass ? '' : ';'));
            }
          }
        });
console.log(filename); // C:\myWorkplace\projectFolder\web\folder\app\plugins\pluginA\style.scss
console.log(ignorePath); // **/plugins/**/*.scss 
(0, _minimatch2.default)(filename, ignorePath);  // false 

But if I change the ignorePath to use back-slash in the pipe.

console.log(filename); // C:\myWorkplace\projectFolder\web\folder\app\plugins\pluginA\style.scss
console.log(ignorePath); // **\plugins\**\*.scss 
(0, _minimatch2.default)(filename, ignorePath);  // true 

I suggest should try to get the path according to linux base style, regardless of what OS we are using.
Alternatively, let say I use Windows for development but Ubuntu for the build, a quick workaround is just append both slash & back slash style to the ignorePaths array.

return gulp.src('./theme/sass/**/*.{scss,sass}')
    // Initializes sourcemaps
        .pipe($.sourcemaps.init())
        .pipe($.sassGlob({
            ignorePaths: [
                '**/plugins/**/*.scss',
                '**\\plugins\\**\\*.scss'
            ]
        }))

This seems a bit silly because I never have to handle these path formatting in any of my gulp task or gulp plugins, but before any new fixes apply, this is they solution.

Hope this will help anyone come across with similar issue

from gulp-sass-glob.

gangsthub avatar gangsthub commented on September 26, 2024

Great point, @paymok! Thank you.

This reminded me to a @sindresorhus' package called slash:
https://github.com/sindresorhus/slash

I would recommend using it or a simmilar one to get the system's slash style.

Also, the article cited it's pretty interesting:
http://superuser.com/a/176395/6877

According to it, as cited from slash readme:

Forward-slash paths can be used in Windows as long as they're not extended-length paths and don't contain any non-ascii characters.

Hope it adds also some light.

Kind regards, Mike

from gulp-sass-glob.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.