【问题标题】:Grunt expand files, what patterns are acceptable in src?Grunt 扩展文件,src 中可以接受哪些模式?
【发布时间】:2013-10-17 16:28:53
【问题描述】:

来自 gruntfile.js 的片段

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

这应该可以according to rubular.

基本上我想编译 'css' 目录中的所有 .scss 文件,除非它们以下划线开头。但是,该模式与任何内容都不匹配?

有什么想法吗?

【问题讨论】:

    标签: javascript node.js sass gruntjs yeoman


    【解决方案1】:

    试试这个模式:['*.scss', '!_*.scss']。它也会使区别更加明确。

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

    如果要递归匹配(cwd 子文件夹中的文件),请使用 **/*

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

    详细了解Grunt Globbing Patterns与正则表达式不同

    【讨论】:

    • 感谢它帮助了我,虽然我认为 RegExp 更适合他们使用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-16
    • 2011-05-05
    相关资源
    最近更新 更多