gruntjs

How can I zip a folder in grunt?

风格不统一 提交于 2019-12-03 12:33:54
I have a folder "foo" , but in my target folder "target" I want to send zip version of my "foo" folder such as "foo.zip" , I google and found many way for zipping files but not for folder, so how can we zip a whole folder in grunt ? The accepted answer was throwing an error in grunt-contrib-compress 0.5.0. Try this instead: compress: { foo: { options: { archive: './foo.zip', mode: 'zip' }, files: [ { src: './foo/**' } ] } } From above suggestion I am able to get my answer,We can use https://github.com/gruntjs/grunt-contrib-compress/ for zipping a folder. compress: { zip:{ files: { './foo.zip':

Use gruntjs as precommit hook

二次信任 提交于 2019-12-03 12:33:17
Is there a way to run a gruntjs task as precommit hook. For example I want do prevent commits with failing tests or jshint issues. I've also think about to run a code beautifier for every commit. Sindre Sorhus Git hooks are just scripts executed when you do an action like commit. They can contain whatever programming language you'd like. Example of triggering grunt: #!/bin/sh grunt Save this in the file: .git/hooks/pre-commit If grunt exits with an error code higher than 0, which it does if any task fail, it will prevent the commit: Exiting non-zero from this hook aborts the commit Reading

Grunt with Compass and Watch compiles slow

这一生的挚爱 提交于 2019-12-03 12:28:32
Grunt takes a quite long to compile the css file, I am not sure if this is normal but regular compass watch takes around 5 seconds. So the question is if there is any way to speed up the compilation time with Grunt or is it better to just stick with compass watch? Running "compass:dist" (compass) task ♀unchanged images/sprite-sf580a96666.png overwrite stylesheets/app.css (3.263s) unchanged images/sprite-sf580a96666.png overwrite stylesheets/app_fr.css (3.289s) Compilation took 11.116s Running "watch" task Completed in 13.974s at Wed Dec 18 2013 13:53:05 GMT-0500 (Eastern Standard Time- Waiting

Passing variable to SASS with Grunt

南笙酒味 提交于 2019-12-03 12:17:51
I want to be able to "@import" a file with SASS depending on a Grunt parameter. With grunt I want to: grunt someTask --skinName=yellow Inside app.scss I want to somehow use this parameter: @import "$skinName"; Some context... This skinName.scss contains a lot of SASS variables with color codes so that I can easily change colors all over the app. I Should be included before all my SASS @imports. You could solve this with another scss file that is written by grunt during the build process: grunt.registerTask('skin', function () { grunt.file.write('skin.scss', '@import "' + grunt.option('skinName

grunt-connect: serve files with base url added

自古美人都是妖i 提交于 2019-12-03 12:17:31
I am developing jekyll-based site using grunt as my task manager. I am using grunt-contrib-connect to serve my files locally for development because of its livereload functionality. Those files are accessible in the browser at: http://localhost:8081/index.html On my server, my files are located within a sub-directory, so have a base url prepended to all urls: http://path.to.server/mysite/index.html I cannot figure out a way to simulate the base url on my local dev setup with grunt-connect. Without that, I don't know how to reference my css or js files without the urls being invalid on either

grunt-wiredep on multiple files with different dependencies

…衆ロ難τιáo~ 提交于 2019-12-03 12:02:27
The current project structure is somewhat like this: -index.html | -bower.json | +-bower_components The proposed project structure will add a few more static html files in the project root. Till now I have been managing all the frontend dependencies in bower.json and had it automatically included in index.html using the grunt-wiredep task. But with new files getting added, each file will have different set of dependencies. -index.html | -file-with-some-other-bower-dependency.html | -bower.json | +bower_components What would be an efficient way of managing these files with different bower

Any equivalent gulp plugin for doing “grunt bower”?

痴心易碎 提交于 2019-12-03 11:55:51
With grunt , I could use command grunt bower (provided by grunt-bower-requirejs ) to auto-generate RequireJS config file for my local bower components. Is there any plugin for gulp to perform similar task? Mind that bowerRequireJS is an asynchronous function. So you would need to use a callback (or synchronously return a Promise) to mark that task as asynchronous like so: gulp.task('bower', function(callback) { var options = { baseUrl: 'src', config: 'src/app/require.config.js', transitive: true }; bowerRequireJS(options, function (rjsConfigFromBower) { callback(); }); }); UPDATE: for future

Change link or script filename in html after gruntjs minify/uglify

断了今生、忘了曾经 提交于 2019-12-03 11:52:58
问题 I am using standard minify/uglify for css/js files and combine multiple files to main.min.css or app.min.js... However my .html file needs to be modified to point to these new file names too in <link> or <script> Is there a way to automate this? Or how to modify .html files automatically to rename the file names in there using gruntjs ? 回答1: You can do this with grunt-string-replace. Here's an example on how you could use it. In my index.html you find the following import tags: <!--start PROD

gruntjs - command line arguments

◇◆丶佛笑我妖孽 提交于 2019-12-03 11:25:11
问题 Where can I get a handle for command line arguments? eg grunt dist --env=UAT . How do I get the value for env ? While I'm at it, how would I assign a default value to this if it's not set on the command line? 回答1: You can use grunt.option() or more specifically: var env = grunt.option('env') || 'default'; to grab the env argument or default to the string 'default' if the argument is not present. 回答2: I find the handling of defaults in grunt to be sorely lacking. The method outlined above

Jenkins script quitting prematurely when using npm install on Windows

穿精又带淫゛_ 提交于 2019-12-03 11:12:09
In my Jenkins job I want to build a JavaScript app using Grunt. The Jenkins build scripts creates a build directory (if it doesn't already exist), changes to that directory and runs: npm install grunt npm install grunt-zip grunt --gruntfile=[something] (Of course grunt-cli is installed globally.) When I build the job, the first statement causes Grunt and dependencies to be pulled down as expected. However, the job then terminates successfully: Archiving artifacts No emails were triggered. Finished: SUCCESS The second npm install is not run. Any idea why the script is terminating after running