Grunt extends files, which patterns are acceptable in src?

Fragment from gruntfile.js file

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, this template does not match anything?

Any ideas?

+4
source share
1 answer

Try this pattern: ['*.scss', '!_*.scss']. This will make the selection more explicit.

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

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

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

Learn more about Grunt globe patterns that don't match regular expressions.

+11

All Articles