gruntjs

Programmatically pass arguments to grunt task?

和自甴很熟 提交于 2019-12-17 10:36:09
问题 I have a grunt task that calls other grunt tasks. I want to call a subtask with programmatically determined arguments. Is this possible? I spent some time digging around the lib/grunt.js and lib/grunt/task.js , but couldn't figure it out. I'm using grunt-compass with the following arguments specified in Gruntfile.js : compass: { default_options: { src: 'components/201', dest: 'build', require: ['zurb-foundation'] } } I want to be able to override them at runtime: tasks/my-task.js : //

Running a command in a Grunt Task

你离开我真会死。 提交于 2019-12-17 10:15:29
问题 I'm using Grunt (task-based command line build tool for JavaScript projects) in my project. I've created a custom tag and I am wondering if it is possible to run a command into it. To clarify, I'm trying to use Closure Templates and "the task" should call the jar file to pre-compile the Soy file to a javascript file. I'm running this jar from command line, but I want to set it as a task. 回答1: Alternatively you could load in grunt plugins to help this: grunt-shell example: shell: { make

How do you watch multiple files, but only run task on changed file, in Grunt.js?

和自甴很熟 提交于 2019-12-17 08:25:22
问题 In learning how to use grunt, I am trying to make a simple coffee-script watcher/compiler. The problem is, if I tell the watch task to watch several files, and one changes, it is going to pass all of the files to the coffee command. This means when you change 1 file, it's going to recompile all of the files matching the src pattern. Instead, I want to only recompile the single file that changed that matches the src pattern. Here is the grunt.js : module.exports = function(grunt) { grunt

How to deploy node app that uses grunt to heroku

狂风中的少年 提交于 2019-12-17 07:02:26
问题 I'm using grunt and also grunt plugins like grunt-contrib-copy , grunt-contrib-mincss (that listed as npm dependencies for my application). Also I don't commit npm_modules folder and public folder, where all generated files are. And I can't figure out how to build my app (I have grunt build command) after deploy and setup my server (it's already looking for public folder). I saw some stuff like grunt-heroku-deploy , but it seems me a bad idea to commit before upload. Maybe there are some

Difference between Grunt, NPM and Bower ( package.json vs bower.json )

一个人想着一个人 提交于 2019-12-17 05:15:13
问题 I'm new to using npm and bower, building my first app in emberjs :). I do have a bit of experience with rails, so I'm familiar with the idea of files for listing dependencies (such as bundler Gemfile) Question: when I want to add a package (and check in the dependency into git), where does it belong - into package.json or into bower.json ? From what I gather, running bower install will fetch the package and put it in /vendor directory, running npm install it will fetch it and put it into

Have Grunt generate index.html for different setups

佐手、 提交于 2019-12-17 04:10:12
问题 I'm trying to use Grunt as a build tool for my webapp. I want to have at least two setups: I. Development setup - load scripts from separate files, without concatenation, so my index.html would look something like: <!DOCTYPE html> <html> <head> <script src="js/module1.js" /> <script src="js/module2.js" /> <script src="js/module3.js" /> ... </head> <body></body> </html> II. Production setup - load my scripts minified & concatenated in one file, with index.html accordingly: <!DOCTYPE html>

How can I run a task in Grunt using an array of filenames which are dynamically generated?

∥☆過路亽.° 提交于 2019-12-14 04:20:23
问题 I am fairly new to using Grunt but have a fairly good understanding of how tasks are installed and run. So far I am able to run everything as I want which includes minifying js, copying files and running jshint. I now want to run 'clean' to remove files from a folder but only an array of selected files which I hope to generate dynamically. So if I had a dynamically generated array e.g. var deleteFilenames = ["file3.js","file2.jpg","file7.html"] etc. How would I set a grunt clean task to just

connect argument is undefined under middleware function

為{幸葍}努か 提交于 2019-12-14 04:08:01
问题 I have connect configuration for - grunt-contrib-connect connect: { options: { ... }, proxies: [{... }], livereload: { options: { base: gruntTargetPath, open: true, middleware: function(connect, options, middlewares) { return [ ..., connect.static('.tmp'), connect().use('/bower_components', connect.static('./bower_components')), connect.static(config.app) ]; } } } } When I execute on bash - grunt connect:livereload , it prompts - Warning: undefined is not a function Use --force to continue.

Grunt task to optionally include an AMD module for different environment

倖福魔咒の 提交于 2019-12-14 03:59:41
问题 I'm developing a web app using Require.js for AMD and amplify.request to abstract away my AJAX calls. The other advantage to amplify.request is that I've defined an alternative module containing mocked versions of my requests that I can use for testing purposes. Currently, I'm switching between the two versions of my request module by simply commenting/un-commenting the module reference in my main.js file. What I'd love to do is use Grunt to create different builds of my app depending on

AngularJS Inject service in .run function

三世轮回 提交于 2019-12-14 03:55:57
问题 In my AngularJS app, using Yeoman, when minifying my app I have this error : Uncaught Error: [$injector:unpr] Unknown provider: aProvider <- a <- $http <- AuthenticationService that I obviously do not have before minifying. Here is the definition of my service in a separate runner.js file : angular.module('myApp').run(['$rootScope', 'AuthenticationService', 'FlashService', 'SessionService', function ($rootScope, AuthenticationService, FlashService, SessionService) { //some code }]); I thought