问题标签 [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.

0 投票
2 回答
5215 浏览

php - 实时重新加载浏览器页面。咕噜和流浪者

对不起我犯的错误,我不是英国人。

所以.. 首先,我有 Vagrant 机器,它是我的 Web 服务器,安装了Yii、Ngnix、PHP 等。vm 配置如下:

其次,我在本地机器上安装了 Grunt,并在通过 nfs 守护进程与 Vagrant 同步的 web 根目录中执行一些任务(查看 *.scss 文件并将它们转换为 css)。

我成功地完成了我的任务并通过浏览器(本地主机:8080)连接到我的网络根目录,一切正常。但是,当 Grunt 监视我的 scss 文件并完成将它们转换为单个 css 文件时,我不明白如何实现简单的重新加载浏览器页面。

有人可以用简单的英语给我一些想法吗?

0 投票
1 回答
1465 浏览

gruntjs - Config Gruntfile.js for livereload

I'm using Laravel as my back-end framework, I would like to have live reloading when some file's modification occurs. I still don't successfully configure the Gruntfile.js to make it works.

I think, I should need 2 plugins, grunt-contrib-watch and grunt-contrib-connect, and I have configured Grutnfile.js as follow.

Please help me to get things right, when things get right, I only have to run as grunt do-connect then grunt will launch the browser for me or I have to open browser and browser to the specified ports manually???

Thanks.

0 投票
2 回答
16652 浏览

gruntjs - How to ignore one file in a grunt-watch task?

I'm trying to exclude the public/build.js file, but it doesn't seem to be working. What am I doing wrong?

0 投票
1 回答
109 浏览

javascript - 将 grunt-contrib-sass 连接到 yeoman 和 grunt-contrib-watch

与这个问题非常相似。

我已经安装了节点库并将其放在我的package.json

并在我的Gruntfile.js

我的文件结构如下所示:

我已经安装了 sass gem。

我确定我在这里遗漏了一些非常基本的东西,需要包括在内。我yo serve似乎没有将文件放在正确的位置以供查找和使用。

我想我在街区里遗漏了一些东西watch,但我不确定那是什么。

0 投票
1 回答
412 浏览

node.js - 总线错误:更新 scss 文件时在 grunt contrib-watch 上出现 10

grunt watch 运行并成功更新 js 更新,但不是 scss。我必须等待大约一分钟才能收到更改。我正在运行节点 v0.10.18

正在运行“监视”任务等待...确定

文件“app/styles/styles.scss”已更改。

总线错误:10`

0 投票
2 回答
3258 浏览

javascript - Odd behavior from grunt-contrib-concat when using globbing pattern

I'm using grunt, and I would like to concat all js files in a certain directory, in a specific order (It's an angular js app, so I want to do my module definitions first, followed by everything else). My grunt concat target looks like:

The above configuration seems like it should concat main-module.js, followed by all other module.js files, followed by everything else, omitting everything in the dist folder. However, the result, when running grunt with --verbose is something like:

This tells me that it's finding the files I want it to find, and then attempting to write (copy?) them to the file path specified in dest. How did I get this so horribly wrong? :) If anyone cares enough to save the last few hairs on my head I would really appreciate some input as to what I'm doing wrong here. I want to concat all the files in src into the dest file.

Edit

If I remove the expand property, the output looks like:

Notice, the third line in the snipped above "Files: ..." lists all the files I wanted it to find, but then says the source file isn't found.

EDIT 2

Matt's solution below takes care of the issue, below is my updated code:

0 投票
4 回答
4287 浏览

coffeescript - 如何使用 grunt-contrib-watch 和 grunt-contrib-coffee 仅在需要时编译 CoffeeScript?

我想只在我保存的单个文件上运行咖啡棉绒和咖啡编译。我的项目中有数百个 CoffeeScript 文件,编译所有这些文件需要太多时间。

这是我的 Gruntfile:

Coffeelint 任务仅在更改的文件上成功运行。

咖啡编译不会产生任何 JS 文件,即使 grunt 说它运行。

这是保存单个咖啡文件后的输出:

这里有什么问题?任何帮助将不胜感激!

更新:

这是一个工作示例:

0 投票
1 回答
4381 浏览

express - 带有 contrib-watch 的 grunt-express-server

我正在尝试同时使用两者grunt-express-servergrunt-contrib-watch但是,一旦我的快速服务器启动,它似乎不再进行任何观看或重新加载。我有服务器设置在后台生成。我的项目在这里:https ://github.com/RyanHirsch/firem

这是我的 Gruntfile.js

0 投票
2 回答
854 浏览

gruntjs - grunt imagemin 创建无限文件夹并警告空文件

我按照我们亲爱的朋友 Chris Coyier 的教程Gruntfile.js正确安装了 imagemin 。它可以编译,但我有两个奇怪的怪癖,基本上是两个问题......

问题一:

图像被创建双倍或三倍,这仅使用一个grunt命令。下面你可以看到命令 grunt 之后创建的文件结构。想象一下,如果watch经常这样做!我需要一个解决方案,因为如果可能的话,我希望这个功能是自动的,有什么帮助吗?

在此处输入图像描述

问题 2:

图像正确缩小,但我总是收到图像为空的错误,如下所示。有趣的是,那个图像已经被制作出来了。我想如果第一个问题得到解决,这个问题很可能会得到解决。在终端输出下方。

终端输出:

这里问的是我的 Gruntfile.js 配置:

0 投票
2 回答
495 浏览

node.js - 同时文件更改后运行一次 grunt-nodemon

这是我的 Gruntfile。我同时运行 nodemon 来运行我的应用程序并观察我的咖啡脚本的变化。

Coffeescript 获取 src 文件并将它们转换为 JS 文件(目前有 3 个,main.coffee、Person.coffee 和 Car.coffee)

我希望我的 Nodemon 在每次这些文件更改时重新启动,以使用最新保存的更改运行它。

问题来了:当只修改了1个 coffee文件时,运行coffee会重新编译所有coffee文件,依次生成3个js文件,依次使nodemon重启3次。这是不可取的,因为我在使用网络请求的应用程序中工作,我不希望它失控。

是否可以让 nodemon 只重启 1 次?

我想连接所有的 JS 文件,但这会弄乱我的 JS 文件的模块化。

我也想过一个接一个地“观看”文件,但如果我达到 50 个文件,那会变得很麻烦。

我怎么解决这个问题?