Skip to content

Instantly share code, notes, and snippets.

@renatoapcosta
Last active April 5, 2018 02:55
Show Gist options
  • Save renatoapcosta/7d6c307cb4ca34f20ef0 to your computer and use it in GitHub Desktop.
Save renatoapcosta/7d6c307cb4ca34f20ef0 to your computer and use it in GitHub Desktop.
Grunt

Grunt

Instalando

sudo npm install -g grunt-cli

sudo npm install -g grunt-init

Criando arquivo package.json

{
	"name": "grunt-projeto",
	"version": "0.1.0",
	"devDependencies": {
		"grunt": "~0.4.5",
		"grunt-contrib-jshint": "~0.10.0",
		"grunt-contrib-concat": "~ 0.4.0",
		"grunt-contrib-uglify": "~0.5.0",
		"grunt-shell": "~0.7.0" 
	}
}

Criando gruntfile.js

module.exports = function(grunt){

	grunt.initConfig({
		jshint:{
			all: ['scripts.js']
		}
	});

	grunt.loadNpmTasks('grunt-contrib-jshint');

	grunt.registerTask('default', ['jshint']);
	
};

Executando Grunt

npm install --save-dev

grunt

Juntando e minificando arquivos

module.exports = function(grunt){

	grunt.initConfig({
		jshint:{
			all: ['scripts.js']
		},
		concat:{
			dist: {
				src: ['scripts.js', 'script1.js', 'script2.js'],
				dest: 'unidos.js'
			}
		},
		uglify:{
			dist:{
				src: ['unidos.js'],
				dest: 'build/unidos.min.js'
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');

	grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
	
};

Rodando comandos

module.exports = function(grunt){

	grunt.initConfig({
		jshint:{
			all: ['scripts.js']
		},
		concat:{
			dist: {
				src: ['scripts.js', 'script1.js', 'script2.js'],
				dest: 'unidos.js'
			}
		},
		uglify:{
			dist:{
				src: ['unidos.js'],
				dest: 'build/unidos.min.js'
			}
		},
		shell: {
			multiple: {
				command: [
					'rm unidos.js',
					'mkdir deploy',
					'mv build/unidos.min.js deploy/unidos.min.js'
				].join(' && ')
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-shell');

	grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'shell']);
	
};
module.exports = function(grunt){
grunt.initConfig({
jshint:{
all: ['scripts.js']
},
concat:{
dist: {
src: ['scripts.js', 'script1.js', 'script2.js'],
dest: 'unidos.js'
}
},
uglify:{
dist:{
src: ['unidos.js'],
dest: 'build/unidos.min.js'
}
},
shell: {
multiple: {
command: [
'del unidos.js',
'mkdir deploy',
'move build\\unidos.min.js deploy\\unidos.min.js'
].join(' && ')
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'shell']);
};
{
"name": "grunt-projeto",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-concat": "~ 0.4.0",
"grunt-contrib-uglify": "~0.5.0",
"grunt-shell": "~0.7.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment