Tag: gruntjs

Gruntfile任务未正常运行

当我在terminal上运行grunt命令时,concat taks不会创buildconcat/form.js ,我需要它来缩小javascript代码。 我有下一个目录结构: src/entry/form.js src/form/simple-form.js 这是我的Gruntfile.js , 有什么不对吗? module.exports = function(grunt){ grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { form: { options: { separator: '' }, dist: { src: ['./src/**/*.js'], dest: './concat/form.js' } } }, uglify:{ form:{ options: { sourceMap: true, souceMapIncludeSources: true }, dist: { files: { 'dist/test.min.js' : ['concat/form.js'] } } } } }); grunt.loadNpmTasks('grunt-contrib-concat'); […]

使用Grunt-babelify-browserify而不导入节点模块

我正在用webdriver.io编写自动化testing。 我正在使用grunt / babelify / browserify,以便我可以在ES6中编写testing。 我在脚本中需要一些节点模块。 我希望能够不将这些节点文件编译到我的分发脚本中,而是直接打印出require语句,因为我仍在运行脚本服务器端。 换句话说,是否有一种方法可以通过browserify“按原样”来代码? 这里是我要求的模块: required libraries var webdriverio = require('webdriverio'); var chai = require("chai"); chai.config.includeStack = true; // prints out full call stack var expect = chai.expect; var chaiAsPromised = require("chai-as-promised"); chai.use(chaiAsPromised); 这是我的咕噜文件: module.exports = function (grunt) { grunt.initConfig({ browserify: { dist: { options: { transform: [ ["babelify", { […]

Grunt:如何只为修改后的文件运行任务?

我有以下gruntfile.js: module.exports = function(grunt) { require('jit-grunt')(grunt); grunt.initConfig({ uglify: { options: { manage: false }, my_target: { files: [{ expand: true, cwd: 'assets/js', src: '*.js', dest: 'min' }] }, }, less: { development: { options: { compress: true, yuicompress: true, optimization: 2 }, files: { "assets/css/styles.css": "assets/less/styles.less" // destination file and source file } } }, […]

如何在Grunt中执行属性预处理?

Grunt具有用于在执行任务之前设置和更新configuration属性的语法。 例如, config { dist: { dir: "dir1" }, clean: { dirs: [ '<dist.dir>' ] } } 成为记忆中的… config { dist: { dir: "dir1" }, clean: { dirs: [ "dir1" ] } } npm模块负责这个? 请告诉我如何以更好的方式实现它? 谢谢!

无法更新新文件中的devDependencies

首先在这里,大家好。 我从Learn Less.js (Packt)学到Less,并遵循它设置环境的步骤(第2章)。 第一次使用node.js,我安装在默认的目录下。 之后,我创build了我的第一个grunt项目并保存了它,然后将cmd导航到其父文件夹并执行npm install -g –save-dev 。 问题:本书断言devDependencies应该更新,但不是。 我的第一个咕噜项目代码: { "name": "my_grunt_project", "version": "0.0.1", "devDependencies": { } } 试着在这里发布一些解决scheme,我试着执行npm update –save-dev ,但收到警告,devDependencies没有更新。 警告是No description , No repository field和No license field 。 将需要什么来得到它更新?

npm WARN弃用xxx:我该怎么办?

我已经使用了几年的咕噜声,而且一直如此,我已经看到如下的警告: npm WARN deprecated win-spawn@2.0.0: use [cross-spawn](https://github.com/IndigoUnited/node-cross-spawn) or [cross-spawn-async](https://github.com/IndigoUnited/node-cross-spawn-async) instead. npm WARN deprecated lodash@0.9.2: lodash@<2.0.0 is no longer maintained. Upgrade to lodash@^3.0.0 npm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0. npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v6.0. Please update to graceful-fs@^4.0.0 as soon […]

在Grunt中创build全局对象

我试图使用includereplace插件的咕噜声。 我想通过使用下面的代码获取一个JSON为globals属性赋值: grunt.registerTask('fetchProperties', 'Fetches the properties.json file', function() { properties = grunt.file.readJSON('properties.json'); grunt.log.writeln(['Properties file loaded']); }); 现在当我做的properties.var_a var_a正确地返回var_a的值。 所以,我这样做了: grunt.registerTask('fetchProperties', 'Fetches the properties.json file', function() { properties = grunt.file.readJSON('properties.json'); grunt.task.run('includereplace'); }) 这是我的includereplace任务: includereplace: { dist: { options: { globals: { VAR_A: properties.var_a, VAR_B: properties.var_b }, }, files: [{ src: '../myFiles/path/to/some/file/main.txt', dest: '../myOtherFiles/path/to/some/file/mainrep.txt' }] } } […]

使用自定义参数执行节点脚本

我有node.js脚本,它使用-b arg1和–parameter arg2参数。 有任何方法传递他们与Grunt任务? 我已经尝试了咕噜执行 , execute: { options: { args :['-b test'] }, target: { src: ['uploader.js'] } }, 但test前总是有空间的

Grunt为摩卡testing提供html报告

我使用grunt来运行我的摩卡testing,我看到在控制台的testing结果是好的,问题是这个任务正在生成报告,但是当你运行这个HTML报告,你只能看到在文本中运行的日志…我希望看到testing聚合 ,和摩卡单位testing运行好,我在这里失踪? mochaTest: { test: { options: { reporter: 'spec', colors: true, summery: true, captureFile: 'results.html', // Optionally capture the reporter output to a file quiet: false, // Optionally suppress output to standard out (defaults to false) clearRequireCache: true // Optionally clear the require cache before running tests (defaults to false) }, src: ['test/*spec.js'], excludes: […]

咕噜打开两个不同的文件

咕噜打开两个不同的文件 我使用grunt-open插件工作正常。 现在我需要用不同的任务打开一个额外的文件。 我怎样才能做到这一点? 我努力了: open: { file: { path: appPath + '/coverage/lcov/index.html', path2: appPath + '/coverage/lcov-report/index2.html' } } //Here I want to open first line grunt.registerTask('openCoverage', ['exec', 'copy', 'mocha_istanbul', 'open:path']); //Here I want to map second line grunt.registerTask('MochaWeb', ['exec', 'copy', 'mochaTest', 'open:path2']);