How grunt watch files in sub folders?

家住魔仙堡 提交于 2019-12-03 04:27:19

问题


My codes folders and files like this, you never know how many sub folders in it:

js/sub1/a.js
js/sub2/b.js
js/sub3/sub31/c.js
js/sub4/sub41/sub411/d.js

Here is part of the Gruntfile.js:

grunt.initConfig({
    watch: {
        src: {
            files: ['js/*.js'],
            tasks: []
        }
    }
});

Grunt can't watch the changes of my all JavaScript files by using 'js/*.js'. So how to write the correct file path expression?


回答1:


Per the official documentation on file globbing, to watch for changes for files of a certain file type in the directory path and its subdirectories, you'll want:

files: ['js/**/*.js']


来源:https://stackoverflow.com/questions/15542520/how-grunt-watch-files-in-sub-folders

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