Grunt expand files, what patterns are acceptable i

2019-06-23 23:54发布

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?

1条回答
爷、活的狠高调
2楼-- · 2019-06-24 00:17

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.

查看更多
登录 后发表回答