[Grunt] Watch && grunt-contrib-watch
amp watch grunt contrib
2023-09-14 08:59:21 时间
Watch is an essential component of any Grunt build, and you will find yourself using it in almost every project.
How to install?
1. Install grunt first if you don't have yet. Check the first article for Grunt.
2. Install grunt-contrib-watch
npm install grunt-contrib-watch
What is watch used for?
A simple example is that, it can watch a file if the file changed then trigger the task to run.
How to use?
You have a log.txt file, and you want to watch this file.
1. load npm task:
grunt.loadNpmTasks('grunt-contrib-watch');
2. set up watch:
grunt.initConfig({ watch: { files: ['log.txt'], tasks: ['pat'] } });
3. add task:
grunt.registerTask('pat', function(){ grunt.log.writeln('I am watching you!'); });
4. Start watch:
#In cmd
$ grunt watch
File the file is modified:
相关文章
- Interview: 2020春季中高级前端面试记 | 渐进增强题目甄选(上篇)-react&http基础
- 每日tips:Dart & Flutter Easy Wins 8-14
- ES 字符过滤器&令牌过滤器
- 关于 Kubernetes中Job&CronJob的一些笔记
- MCE | 单胺能 & 非单胺能对抑郁症的作用
- 业务安全之短信&邮箱验证码
- Cookie & Session
- 【动态内存管理】malloc&calloc和realloc和笔试题和柔性数组
- matlab绘图(六)-图像光滑&数据取点
- 7 Papers & Radios | 纯注意力或许没那么有用;从量子场看深度学习
- 使用Redis集群的Watch技术监控数据(redis集群watch)
- 聊天室php&mysql(三)
- JavaScript.The.Good.Parts阅读笔记(二)作用域&闭包&减缓全局空间污染