Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt expand files, what patterns are acceptable in src?

Snippet from gruntfile.js

sass: {
    compile: {
        files: [{
            expand: true,
            cwd: 'css/',
            src: ['^[^_].scss'],
            dest: '../css/',
            ext: '.css'
        }]
    }
},

This should work according to rubular.

Basically I want to compile all .scss files in the 'css' directory, unless they start with an underscore. However, that pattern doesn't match anything?

Any ideas?

like image 643
zkwentz Avatar asked Dec 20 '22 23:12

zkwentz


1 Answers

Try this pattern: ['*.scss', '!_*.scss']. It'll make the distinction more explicit, too.

sass: {
    compile: {
        files: [{
            expand: true,
            cwd: 'css/',
            src: ['*.scss', '!_*.scss'],
            dest: '../css/',
            ext: '.css'
        }]
    }
},

If you want to match recursively (files in subfolders of cwd), use **/*

sass: {
    compile: {
        files: [{
            expand: true,
            cwd: 'css/',
            src: ['**/*.scss', '!**/_*.scss'],
            dest: '../css/',
            ext: '.css'
        }]
    }
},

Learn more about Grunt Globbing Patterns, which aren't the same as regular expressions.

like image 126
bevacqua Avatar answered Jan 18 '23 15:01

bevacqua