gruntjs

How to include a static JSON file for compilation with Jade and Grunt

坚强是说给别人听的谎言 提交于 2019-12-24 02:01:50
问题 how do I compile Jade templates to static HTML via Grunt where my data is already held in a JSON file? Say I have this Gruntfile.js module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-jade'); grunt.initConfig( { jade: { html: { src: './*.jade', dest: './index2.html', options: { client: false, pretty: true } } } }); grunt.registerTask('default', 'jade'); }; This JSON file (./data.json) { "foo": {value: 1}, "bar": {value: 2}, "baz": {value: 3} } And this Jade (./index.jade) ul

ReferenceError: can't find variable x when using grunt test in yeoman

狂风中的少年 提交于 2019-12-24 01:56:07
问题 I'm using yeoman, grunt, mocha. I want to do BDD so I make basic unit test and run grunt test in console, which gives me ReferenceError: can't find variable: Creature opening test/index.html in browser works as it should. This is my creature.js file in app/scripts: 'use strict'; var Creature = (function () { function Creature(name) { this.name = name; } Creature.prototype.sayHello = function (message) { return this.name + ' ' + message; }; Creature.prototype.eat = function (item){ return this

Injecting content via Grunt task, depending on asp.net project build configuration

こ雲淡風輕ζ 提交于 2019-12-24 01:55:24
问题 I'm trying to inject content via grunt-replace when I build by visual studio solution. However I would like to inject different content depending on the build configuration. Is it possible to read the build configuration using grunt/node. Thanks. 回答1: You can use grunt.option for this. Provide your build env on the command line and use it in the Gruntfile using grunt.option. Quoting the example from grunt.option documentation Gruntfile.js grunt.initConfig({ compass: { dev: { options: { /* ...

Grunt install error/s: “should be installed with -g”

故事扮演 提交于 2019-12-24 01:53:37
问题 I'm trying to install Grunt on my machine. I have read some tutorials and followed the installation docs, but I can't get it working. The CLI installs ok using this command: sudo npm install -g grunt-cli When I select a local directory (containing the package.json and Gruntfile) and npm install , I see the following message: npm WARN prefer global grunt-cli@0.1.9 should be installed with -g Why is this happening? I did install with -g - meaning 'globally', I understand. After this, it seems

yeoman build the compass bootstrap scss images path always prefix '../'

别等时光非礼了梦想. 提交于 2019-12-24 01:07:34
问题 the problem is in bootstrap sass , icon sprites path is all ways prefix '../' before the image, '../../images/../images/glyphicons-halflings-white.png' I hope like this '../images/../images/glyphicons-halflings-white.png' grunt files config : options: { sassDir: '<%= yeoman.app %>/styles', cssDir: '.tmp/styles', imagesDir: 'images', javascriptsDir: '<%= yeoman.app %>/scripts', fontsDir: '<%= yeoman.app %>/styles/fonts', importPath: '<%= yeoman.app %>/components', relativeAssets: true }, How

Grunt cssmin / CleanCSS source map rebasing

不打扰是莪最后的温柔 提交于 2019-12-24 00:57:45
问题 I'm using cssmin with the following "Content" folder structure: src |--dir1 | |--style1.css | |--images | |--image1.png |--dir2 |--style2.css |--images |--image2.png dist |--styles.min.css |--styles.min.css.map Where styles.min.css and styles.min.css.map are the result of concatenating/minifying all stylesheets in the"src" folder. I first had issues where styles.min.css contained URLs for images in the wrong places (i.e. "images/image1.png" instead of "../src/dir1/images/image1.png") but

How to bind a custom event to the grunt task runner in VS 2013

て烟熏妆下的殇ゞ 提交于 2019-12-23 22:54:03
问题 I'm aware of the task runner as a visual studio extension, you can bind a grunt task to a specific visual studio "event" like: before build after build clean open solution In my case I want to automate the deploy process to run a build task using grunt (clean, minify, concat files, etc.) before creating a deploy package when publishing a website in visual studio . I also want to do some modifications to the deploy package instead to pickup the whole list of files in the main directory I'd

Can an assemble target be silenced if there are no matching files? (Without using --force)

五迷三道 提交于 2019-12-23 19:13:41
问题 I have this assemble grunt target: docs: { files: {'<%= site.tmp %>/': ['<%= site.pages %>/**/*.html'] } }, If there is no matching content, it complains, saying "Warning: Source files not found. Use --force to continue". The task then aborts. I don't mind the warning but I would like the option to configure the task to continue rather than having to use "--force" on the command line. Is this possible? ps. The reason why this task is now failing is that I have converted the content to

Task not found using grunt

让人想犯罪 __ 提交于 2019-12-23 17:27:37
问题 I'm trying to use multiple tasks in grunt, one of them is working partialy, and the other is getting erros of not found task . This question is based on this one, where I'm using the same gruntfile.js and the same structure, which is this: ├── Gruntfile.js └── grunt ├── config │ ├── conf_sass.js │ └── conf_home.js └── register ├── reg_sass.js └── reg_home.js With this respective files: conf_sass.js module.exports = function(grunt) { grunt.config.set('sass', { sass: { options: { style:

Grunt task to wait for exit

 ̄綄美尐妖づ 提交于 2019-12-23 17:03:38
问题 I've got a task that starts IIS Express async, and to stop IIS I have to fire a grunt event. I would like to make a task that just waits until i press ctrl-c and then fires that event. I've tried doing this: grunt.registerTask("killiis", function(){ process.stdin.resume(); var done = this.async(); grunt.log.writeln('Waiting...'); process.on('SIGINT', function() { grunt.event.emit('iis.kill'); grunt.log.writeln('Got SIGINT. Press Control-D to exit.'); done(); }); }); The task stops grunt