gpt4 book ai didi

node.js - Grunt 执行多次,创建无限循环

转载 作者:太空宇宙 更新时间:2023-11-04 02:18:33 25 4
gpt4 key购买 nike

我们正在与 GIT 上的其他几个开发人员一起开发一个项目,使用相同的存储库,它与其他人一起工作得很好。然而,当我运行 grunt 时,它会执行多次,似乎进入了无限循环,而我实际上没有进行任何更改。仅在另一台计算机上发生在我身上我正在考虑也许我需要安装其他东西。我删除了 node、npm 并重新安装了自制软件,我也用它来进行更新。 Node v5.3.0、npm 3.3.12运行小牛队。

我错过了什么?

这是循环:

    Reloading watch config...

Running "watch" task
Waiting...
>> File "Gruntfile.js" changed.
>> File "js/all-js/bootstrap-hover-dropdown.min.js" changed.
>> File "js/all-js/site.js" changed.
Running "uglify:build" (uglify) task
>> 1 file created.

Done, without errors.
Completed in 3.740s at Tue Jan 05 2016 13:11:07 GMT-0500 (ECT) - Waiting...
[BS] File changed: js/site.min.js

Reloading watch config...

Running "watch" task
Waiting...
>> File "js/all-js/bootstrap.js" changed.
>> File "Gruntfile.js" changed.
Running "uglify:build" (uglify) task
>> 1 file created.

Done, without errors.
Completed in 1.869s at Tue Jan 05 2016 13:11:10 GMT-0500 (ECT) - Waiting...
[BS] File changed: js/site.min.js
>> File "js/all-js/bootstrap-hover-dropdown.min.js" changed.
Running "uglify:build" (uglify) task
>> 1 file created.

Done, without errors.
Completed in 1.885s at Tue Jan 05 2016 13:12:04 GMT-0500 (ECT) - Waiting...
[BS] File changed: js/site.min.js

Reloading watch config...

Running "watch" task
Waiting...
>> File "Gruntfile.js" changed.

这是我的 Gruntfile.js:

    module.exports = function(grunt) {

//Get all tasks from the package.json file
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

/* Concurrent Task */

concurrent: {
watch: {
tasks: ['watch', 'compass:dist', 'browserSync'],
options: {
logConcurrentOutput: true
}
}
},

/* SASS task */

compass: {
dist: {
options: {
sassDir: ['SASS/'],
cssDir: ['css/'],
environment: 'development', /* development | production */
importPath: ['SASS/'],
outputStyle: 'compressed', /* expanded for development | compressed for production */
watch: true,
sourcemap: true
},
},
live: {
options: {
sassDir: ['SASS/'],
cssDir: ['css/'],
environment: 'production', /* development | production */
importPath: ['SASS/'],
outputStyle: 'compressed', /* expanded for development | compressed for production */
watch: false,
force: true,
},
},
},

/* Javascript Tasks */

uglify: {
// Uglify files

build: {
src: [
'js/all-js/bootstrap.js',
'js/all-js/site.js'
],
dest: 'js/site.min.js'
}

},

/* Run tasks when needed */

watch: {
js: {
files: ['js/all-js/*.js'],
tasks: ['uglify'],
options: { livereload: true }
},
gruntfile: {
files: ['Gruntfile.js'],
options: {reload: true}
}
},

/* Browser Reload with BrowserSync */

browserSync: {
bsFiles: {
src : [
'css/**/*.css',
'js/site.min.js',
'**/*.php'
]
},
}


});

// Where we tell Grunt what to do when we type "grunt" into the terminal.

grunt.registerTask('default', ['concurrent:watch']);
grunt.registerTask('live', ['compass:live']);

};

这是我的 package.json 文件:

    {
"name": "ourframework",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-compass": "*",
"grunt-browser-sync": "*",
"grunt-contrib-watch": "*",
"grunt-concurrent": "*",
"grunt-contrib-uglify": "*",
"matchdep": "*"
}
}

最佳答案

查看 grunt 输出中的时间戳,例如:

Completed in 3.740s at Tue Jan 05 2016 13:11:10
Completed in 1.885s at Tue Jan 05 2016 13:12:04

请注意,这些编译相隔一分钟 - 您正在运行 grunt watch 任务。这将监视一组指定的文件,并在有任何更改时重新运行任务。

没有“循环” - 每次发生变化时它都会简单地重新编译,这通常是可取的。

您可以看到默认任务设置为concurrent:watch

grunt.registerTask('default', ['concurrent:watch']);

因此,如果您只需输入 grunt,它就会运行该任务。

关于node.js - Grunt 执行多次,创建无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34618947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com