我应该指出我没有经验的用户优先,我的问题是'hostname'属性不能分配任何值,除了空字符串(''),'0.0.0.0'和'localhost'.我得到:致命错误:getaddrinfo ENOTFOUND.我究竟做错了什么?
如果做对了,我可以改变我通常在地址栏中输入的地址,所以改为'localhost'我可以键入'example.com'或类似的东西.
正如我上面提到的,我已经为它分配了不同的值,但只有三个有效.那么为什么这个'*'不起作用.
这是My Gruntfile.js:
module.exports = function( grunt ) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
scripts: {
files: ['*.js'],
options: {
livereload: true
}
},
markup: {
files: ['*.html'],
options: {
livereload: true
}
},
stylesheets: {
files: ['*.css'],
options: {
livereload: true
}
}
},
connect: {
server: {
options: {
hostname: '*',
port: 2000,
base: '.'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['connect','watch']);
};
Run Code Online (Sandbox Code Playgroud)
在Ubuntu 12.04 64bit上工作
NodeJs 0.10.17
npm …
我有一个项目使用GruntJS与grunt-contrib-sass,grunt-contrib-watch和grunt-newer.
我的主要app.scss文件使用@import指令导入一些.scss文件
@import"common/vars.scss";
如果我在主app.scss中进行更改,一切正常.问题是,当我对正在导入的文件(如vars.scss)进行更改时,app.scss不会更新.
这是我的观察任务:
watch: {
css: {
files: ['scss/**/*.scss'],
tasks: ['newer:sass'],
options: {
spawn: false,
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是sass的任务本身:
sass: {
dist: {
options: {
style: 'compressed',
noCache: true
},
/* looks for every .scss file in the scss folder (checks nested folders too),
* compile it and create another file wit the same name in the style folder */
files: [{
expand: true,
cwd: 'scss',
src: ['**/*.scss'],
dest: 'style',
rename: function (dest, src) {
var folder = …Run Code Online (Sandbox Code Playgroud) 我无法配置Grunt来查看我的项目文件,重建和更新连接服务器中托管的页面.如果我运行任何构建任务,然后'watch'作为组合任务的一部分,那么'watch'似乎陷入循环,无休止地打印消息.
Running "watch" task
Waiting...
Warning: must provide pattern
Run Code Online (Sandbox Code Playgroud)
如果我只是运行$ grunt watch,它会愉快地观察我的源文件并编译/构建.
我认为相关的任务配置是这些:
watch: {
html: {
files: [ '<%= site.partials %>', '<%= site.layouts %>', '<%= site.pages %>' ],
tasks: [ 'html' ]
},
sass: {
files: [ '<%= site.src %>sass/*.scss' ],
tasks: [ 'styles' ]
}
},
// development server
connect: {
options: {
port: 8080,
livereload: 35729,
hostname: 'localhost',
},
dev: {
options: {
directory: 'build',
}
}
},
Run Code Online (Sandbox Code Playgroud)
和任务定义:
grunt.registerTask( 'build', …Run Code Online (Sandbox Code Playgroud) 我一直在寻找一种方法的示例,以便在发生文件更改时使用Grunt的监视模块执行几个步骤.我还没有找到任何一个很好的例子,所以如果有人能指出我的方向很好.
我尝试了一些不同的方法,例如使用Grunt启动子进程,但我总是最终处理悬空进程,锁定端口,错误的STDIO或其他问题.如果Grunt进程退出,我希望杀死子进程.
有没有一个好方法来处理这个?谢谢!
我正在使用grunt,我想按特定顺序连接某个目录中的所有js文件(它是一个角度js应用程序,所以我想首先执行我的模块定义,然后是其他所有内容).我的grunt concat目标看起来像:
concat: {
mobile: {
expand: true,
cwd: "static/javascript/mobile/app/",
src: ["main-module.js", "**/*-module.js", "**/*.js", "!static/javascript/mobile/dist/*"],
dest: "static/javascript/mobile/app/dist/ngmobile.concat.js"
}
}
Run Code Online (Sandbox Code Playgroud)
上面的配置好像应该连接main-module.js,然后是所有其他module.js文件,然后是其他所有内容,省略dist文件夹中的所有内容.但是,当使用--verbose运行grunt时,结果如下:
Running "concat:mobile" (concat) task
Verifying property concat.mobile exists in config...OK
Files: static/javascript/mobile/app/main-module.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/main-module.js
Files: static/javascript/mobile/app/clients/clients-module.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/clients/clients-module.js
Files: static/javascript/mobile/app/reports/reports-module.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/reports/reports-module.js
Files: static/javascript/mobile/app/schedules/schedules-module.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/schedules/schedules-module.js
Files: static/javascript/mobile/app/services/services-module.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/services/services-module.js
Files: static/javascript/mobile/app/clients/addclient-ctrl.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/clients/addclient-ctrl.js
Files: static/javascript/mobile/app/clients/clientprofile-ctrl.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/clients/clientprofile-ctrl.js
Files: static/javascript/mobile/app/clients/clients-ctrl.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/clients/clients-ctrl.js
Files: static/javascript/mobile/app/clients/clients-service.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/clients/clients-service.js
Files: static/javascript/mobile/app/common/directives.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/common/directives.js
Files: static/javascript/mobile/app/common/filters.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/common/filters.js
Files: static/javascript/mobile/app/common/header-ctrl.js -> static/javascript/mobile/app/dist/ngmobile.concat.js/common/header-ctrl.js …Run Code Online (Sandbox Code Playgroud) 我像这样制作了Gruntfile.js:
'use strict';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-favicons');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-bake');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-cwebp');
grunt.loadNpmTasks('grunt-responsive-images');
grunt.loadNpmTasks('grunt-retinafy');
grunt.loadNpmTasks('grunt-spritesmith');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-contrib-watch');
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
watch: {
html: {
files: ['./assets/**/*.html'],
tasks: ['html'],
options: {
spawn: false,
livereload: true,
},
},
less: {
files: ['./assets/less/**/*.less'],
tasks: ['less_files'],
options: {
spawn: false,
livereload: true,
},
},
js: {
files: ['./assets/js/**/*.js'],
tasks: ['js'],
options: {
spawn: false,
livereload: true,
},
},
img: {
files: ['./assets/images/**/*.png'],
tasks: ['img'],
options: {
spawn: …Run Code Online (Sandbox Code Playgroud) 期待 Sassier Bootstrap 4,我(试图)在 Bootstrap 3.3.5 上从 Less 切换到 Sass 并设置所需的Gruntfile.js文件。我没有问题,编制少,但不能让步兵与萨斯工作,特别是,$ grunt和$ grunt watch这两个让我
Running "watch" task
Waiting...
永远。
不用说它不会编译。我试过了$ grunt watch --verbose,得到了很多绿色OK的。
我想我有一些错误或效率低下,gruntfile.js但由于这是 Baby 的第一个 Gruntfile.js,我被困在这里。你能看出是什么原因造成的吗?
/*** Created by morgan on 9/13/15. */
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dev: {
options: {
includePaths: ['static/sass']
},
dev: {
options: {
style: 'expanded',
compass: false
},
files: {
'css/styles.css': 'sass/styles.scss'
}
}
} …Run Code Online (Sandbox Code Playgroud) 我有这个工作流程:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
grunt.initConfig({
sass: {
options: {
sourceMap: true
},
dist: {
}
},
watch: {
files: ['src/*.scss'],
tasks: ['sass']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ["sass"]);
};
Run Code Online (Sandbox Code Playgroud)
运行grunt watch并更改src/*.scss文件后,我得到:
文件"src/main.scss"已更改.运行"sass:dist"(sass)任务
完成,没有错误.2016年2月2日星期二02:25:11 GMT + 0100(CET)完成0.949秒 - 等待...
我的问题:生成的文件在哪里?如何指定目标文件?
我也尝试过使用这个工作流程:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
grunt.initConfig({
sass: {
options: {
sourceMap: true
},
dist: {
files: [{
expand: true,
cwd: 'src',
src: ['*.scss'],
dest: '.', …Run Code Online (Sandbox Code Playgroud) 我不是一个亲与繁重的,但我有我想用我的应用我试图让浏览器中打开automaticaly咕噜时启动,并重新加载页面时HTML,JS和CSS文件被修改我的角度JS模板添加了监视和livereload,但它不会工作我的代码有什么问题
这是我的gruntfile.js
module.exports = function(grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-serve');
var pkg = grunt.file.readJSON('package.json');
var options = {
paths: {
app: 'app',
assets: 'app/assets',
dist: 'app/dist',
distAssets: 'app/dist/assets',
html: 'app/html',
htmlTmp: '.tmp/htmlsnapshot',
htmlAssets: 'app/html/assets',
index: 'app/dist/index.html',
indexDev: 'app/index.dev.html',
indexTmp: '.tmp/html/index.html'
},
watch: {
js: {
files: ['Gruntfile.js', 'app/assets/js/**/*.js'],
tasks: ['jshint'],
options: {
livereload: true
}
},
css: {
files: [
'app/assets/css/**/*.scss'
],
tasks: ['sass'],
options: {
livereload: true
}
},
livereload: {
options: {
livereload: true …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装一些 Grunt 插件,例如grunt-contrib-clean并grunt-contrib-watch
使用npm install grunt-contrib-clean --save-dev
和npm install grunt-contrib-watch --save-dev
我收到了这些警告:
npm WARN stellarhse@1.0.0 需要 grunt@~0.4.0 的同级,但没有安装。您必须自己安装对等依赖项。
npm WARN grunt-contrib-concat@0.3.0 需要 grunt@~0.4.0 的同级,但没有安装。您必须自己安装对等依赖项。
npm WARN grunt-contrib-cssmin@0.10.0 需要 grunt@~0.4.1 的同级,但没有安装。您必须自己安装对等依赖项。
我该如何修复它们?
谢谢你。
gruntjs ×10
javascript ×3
node.js ×3
angularjs ×2
npm ×2
gruntfile ×1
macos ×1
sass ×1
typescript ×1