gruntjs

How to stop minification of js files in grunt?

徘徊边缘 提交于 2020-01-13 08:41:40
问题 I am new to grunt. I have nearly 20-30 js files in my project. I came to know that We are already using grunt to minify and concatenate them. For debug purpose I need to stop minification but retain them in concatenated form. Could any one suggest how to proceed. Any site which has the related tutorials would be helpful.Thanks in advance. module.exports = function(grunt) { var readJSFile = function(data, path){ var finalArray = []; if(path == 'assets/js/'){ finalArray.push('<%= copy.options

Compile LESS with different variables using grunt

眉间皱痕 提交于 2020-01-13 03:47:33
问题 I have HTML template based on Bootstrap, that have different colors (red, green, etc.). Colors are changing using @brand variable in variables.less . Now I go to this file, change variable, compile less files, go to compiled css files directory and rename CSS file according it's color ( red.css , green.css , etc.). And I make this steps 7 times (7 colors = 7 steps). Can I automate this process using grunt or something like this and how? 回答1: Using grunt-contrib-less you can overwrite any

Avoid Grunt cssmin task to remove duplicate entries

不打扰是莪最后的温柔 提交于 2020-01-13 03:12:11
问题 In my Gruntfile I'm using cssmin (grunt-contrib-cssmin) task. Something like: cssmin: { css : { src: "dist/styles.css", dest: "dist/styles.min.css" } } The problem is: styles.css is generated with a concat task that concatenates lots of .css files. In some of files I have the same css selector (example: .panel a) Only the first one selector is kept bu the cssmin task, all others are removed. I guess it's a default behaviour of the task. Is there a way to keep duplicated selectors? 回答1: Grunt

How use require inside a spec - grunt + karma + jasmine in node

余生颓废 提交于 2020-01-13 02:55:08
问题 Vague version question: How can I use require inside a spec with grunt? Context: I'm working on an existent node project that has no tests yet, so I read some and realized to use karma and jasmine. I read some tutos (including these): http://kwilson.me.uk/blog/use-karma-and-grunt-to-run-your-jasmine-tests-in-real-time/ http://ahexamples.blogspot.com.br/2014/03/example-of-jasmine-karma-sonar-grunt.html So I'm trying to run my specs with grunt and getting this error: X encountered a declaration

Compass and Susy require a different version of Sass

佐手、 提交于 2020-01-12 05:46:05
问题 I am working on my website and I want to use Susy as well as Compass. I am using Grunt too. When I run my grunt task I get this error: Denniss-MacBook-Pro:portfolio dennis$ grunt --trace Running "compass:dev" (compass) task Gem::LoadError on line ["1990"] of /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb: Unable to activate susy-2.1.1, because sass-3.2.17 conflicts with sass (~> 3.3.0) Run with --trace to see the full backtrace Warning: ↑

grunt connect port option ignored

末鹿安然 提交于 2020-01-11 10:37:11
问题 I am unable to get grunt connect to use the port that I specify in the options. In my grunt file is the following configuration connect: { options: { port: 9000, hostname: '0.0.0.0' }, test: { options: { port: 9001, open: true, base: 'test' } } } However when I run grunt connect:test the console raises returns the following Opening server for /home/peter/Projects/HammerHead2 on port 1337. 回答1: Simple solution I had install grunt-connect NOT grunt-contrib-connect 来源: https://stackoverflow.com

Node JS - child_process spawn('npm install') in Grunt task results in ENOENT error

依然范特西╮ 提交于 2020-01-11 04:59:25
问题 I'm having some difficulty with a Grunt task I'm authoring. I'm trying to execute npm install, followed by bower install, followed by a grunt hub target (to trigger a build command for multiple sub-projects). The problem I'm encountering lies with child_process. I get spawn ENOENT error if I run the following commands in my grunt task, with the npm install spawn command that's currently commented out: var path = require('path'), projectPath = path.resolve(process.cwd(), this.data.activity );

Grunt - Command Line Arguments, not working

白昼怎懂夜的黑 提交于 2020-01-09 09:33:33
问题 I am using command line options in my grunt script: http://kurst.co.uk/transfer/Gruntfile.js However the command grunt --vers:0.0.1 always returns 'undefined' when I try to get the option: var version = grunt.option('vers') || ''; Can you help me get this working ? I tried different (CLI) commands: grunt vers:asd grunt -vers:asd grunt vers=asd as well as using : grunt.option('-vers'); grunt.option('--vers'); But no luck so far. Hopefully I am missing something simple. This is my package.js

Validate javascript inside attributes

自古美人都是妖i 提交于 2020-01-07 09:06:22
问题 I am using Knockout a lot and often times I have to write scripts inside the data-bind attributes. Is there any validation tools that I can use on these markup files to validate the javascript inside data-bind attributes? Would be nice if there is a grunt plugin. 回答1: There probably isn't (a prominent) one, because it's not common to have a lot of complex logic inside your view. With MVVM-like approaches it works best if you keep the View rather plain, and write out logic in your ViewModel

Run project exsiting HTML file after code coverage finish in grunt

假装没事ソ 提交于 2020-01-07 07:43:51
问题 I've node app which use grunt to generate code coverage report this report is located under and I was able to run it manually myAPP -coverage -index.html I want that when the task of coverage will finish and the report is generated to run this index.html in the browser,how should I do that? I found this https://www.npmjs.com/package/grunt-run but its not working I try many ways grunt.initConfig({ run: { commands: { exec: '/coverage/lcov-report/index.html', } } }); or grunt.initConfig({ run: {