问题标签 [grunt-contrib-watch]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - 更新多个文件时,如何防止 grunt 多次实时重新加载?
我有一个 grunt watch 任务,其中包含多个子任务,用于观看 LESS、CoffeeScript 等。
我还编写了一个自定义任务,负责处理一组经常更新的第 3 方文件。任务更新第 3 方 javascript 和 html 文件中的多个路径,然后将它们重新分配到主项目中的适当位置。
问题是当这些文件中的每一个都被写入它们的目的地时,相关的 grunt 任务会运行,每个都会触发实时重新加载。因此,如果写入 4 个文件,则会发生 4 次单独的重新加载。
有没有办法配置监视任务以将所有实时重新加载事件合并到“结束”时的单个重新加载中?
jasmine - Watcher 在 Grunt 中不起作用
您好,我正在尝试用 grunt 设置一个观察者,但我得到的只是控制台中的这个。
$ grunt watchTest
运行“监视”任务
等待...$
所以没有实际的等待。我已经尝试了 jasmine 任务,它按预期工作。我错过了什么?
javascript - Grunt watch not working
I tried to run the watch task by grunt in node.js but it doesn't work for me (this is what I got):
This is the part of the watch task in the Gruntfile.js:
node.js - GruntJS + contrib-coffee:编译但保持文件夹结构
我将GruntJS与grunt-contrib-coffee一起使用。效果很好!在Watch插件的帮助下,它会更好。但这是我的疑问:
我有两个文件夹,一个是我的咖啡脚本文件,另一个是我的(编译的)js 文件。看起来像这样
当我使用coffee --output --compile
命令构建时,文件夹结构被保留:Coffeescript cli 编译“核心”文件夹并在 Main.js 中。
但是当我运行 GruntJS 时,它会将所有文件放在同一个文件夹(ppalmeida)中。所以控制器、核心、模型文件都放在同一个文件夹中,我不想要。
这是我的glob_to_multiple
配置:
所以,最后我得到了这样的东西:
所以。有没有办法用 contrib-coffee 编译并避免将所有 js 文件放在同一个文件夹中?
谢谢你们。
PS:我不知道它是否有帮助,但这是我完整的 Gruntfile.coffee:
javascript - Node.js/Grunt - 无法运行 Grunt 的手表 - 为什么?
我正在尝试使用 autoprefixer css 后处理器。我正在学习教程并安装了 npm。package.json
使用 npm,然后我使用该文件在我的项目根目录中安装了 grunt 和 autoprefixer : https ://github.com/nDmitry/grunt-autoprefixer/blob/master/package.json
按照教程,然后Gruntfile.js
我在我的项目根目录中创建了这个:
之后,本教程建议使用 Grunt Watch 使用
这导致
我还尝试导航到项目中的 grunt 文件夹,然后显示
我在我的本地用户文件夹中也有一个node_modules
文件夹,但是解决该文件夹 grunt 也只是告诉我它是一个文件夹。
请帮助我,为什么这不起作用?我愿意真正学习 grunt,但我什至无法使用入门指南开始...
gruntjs - grunt watch livereload 致命错误:端口 35279 已被另一个进程使用
我正在尝试将 livereload 与手表一起使用。我不断收到消息“致命错误:端口 35279 已被另一个进程使用”。我已经更改了 livereload 的端口,但没有重新加载。
}
node.js - Configure grunt watch to run Jasmine tests against an app using requirejs
In an attempt to level up my general coding skills... and to learn something new. I've started attempting to wire up a front end only solution consisting of
- Durandal
- Jasmine - [added via npm]
- Grunt Watch to monitor & run my tests as my code files change - [added via npm]
Feel free to correct me, as this is all based on my experimentation in the last 2 days. Most of this is new to me. My goal is to have something similar as to what angular has with karma.
Now I am aware that that the Durandal project (comes with a custom spec runner, as found in the github solution)
My setup:
gruntfile.js
SpecRunner.js
When I run grunt, I get a Illegal path or script error: ['plugins/http']
(I've sorted out the ko issue in the screenshot)
Question:
How would i go about setting up my gruntfile to require any dependencies. I'm quite new to require, and I'm not sure how to configure it to make my tests aware of where to find things like 3rd party libraries and other custom js files for that matter
wordpress - Gruntfile.js 观看
所以我正在制作自己的 Wordpress 框架,并使用 grunt 和 sass。我在 grunt 和 sass 方面较新,但对 grunt 的经验足够了解我在做什么,但我过去使用过 LESS 而不是 Sass。
我以roots.io 中的Gruntfile.js文件作为起点。据我所知,我所拥有的一切都是正确的,但我对一些事情不太确定。我删除了 js 的东西,因为我不会关注它,我添加了 grunt-contrib-sass。
运行 grunt watch 时出现此错误:
下面是我的 Gruntfile.js 和我的 package.json
Gruntfile.JS
package.json - 取出一些东西以保留一点隐私
提前感谢您的帮助。
php - 使用 Grunt.js 监听 PHP 文件
我仍然是一个 Grunt 新手,我在“观看”php 文件时遇到了困难。
发生的情况是 livereload 对于任何 php 文件都可以正常工作,但是我想启动的关于 php 文件更改的任何任务都不会发生......在这种情况下,我想使用 ftp-deploy 来推送 ftp 文件每次更改时到我的服务器(这样我可以通过直接链接到我的服务器上的 php 文件并使用简单的 MAMP 安装来保持我的工作流程)。
我的手表代码是这样的:
因此,即使是 php 文件的 livereload,一切都可以正常工作,除了 ftp-deploy 任务没有发生的巨大例外。
如果我将该 ftp-deploy 任务添加到 sass 目标或 concat 目标上,它可以完美运行,但在香蕉目标上(是的......我开始感到沮丧)它根本不起作用!
我用这个打破了我的头......
有人可以帮我吗?
提前致谢。
gruntjs - 如何让 grunt-watch 在不同的构建任务下实时重新加载 HTML 更改
我可以通过执行以下操作轻松设置我的 Grunt 文件以实时重新加载 HTML 和 SCSS 更改:
但是,我有一个用于开发环境的构建任务:dev
和一个用于生产环境的构建任务:build
。因此,在 HTML 更改时调用build
将构建用于生产的站点,如果我只想要开发版本,这不是我想要的。
理想情况下,我会做类似的事情:
从而能够调用watch:dev
or watch:dist
,但是此代码不起作用。
我能想到的唯一解决方法是:
再次调用watch:dev
or watch:dist
,但这样做的缺点是我不想在只更改少量 SCSS 时重建整个站点。
有什么方法可以实现我所追求的吗?