Grunt expand files, what patterns are acceptable in src?

匆匆过客 提交于 2020-01-03 19:33:31

问题


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:


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.



来源:https://stackoverflow.com/questions/19286848/grunt-expand-files-what-patterns-are-acceptable-in-src

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