Skip to content

Instantly share code, notes, and snippets.

@diogovk
Created December 18, 2014 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogovk/19a8106329b8d0f5224d to your computer and use it in GitHub Desktop.
Save diogovk/19a8106329b8d0f5224d to your computer and use it in GitHub Desktop.
### Grunt Dependencias ###
"envify": "~1.2.1",
"grunt": "~0.4.4",
"grunt-browserify": "~1.3.2",
"grunt-contrib-watch": "~0.6.1",
"grunt-env": "~0.4.1"
#Note que não faz o uglify!
#### Grunt ####
var fs = require('fs');
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
env: {
build: {
NODE_ENV: 'production'
}
},
browserify: {
dev: {
options: {
debug: true,
transform: ['reactify']
},
files: {
'public/build/build.js': 'public/js/**/*.jsx'
}
},
build: {
options: {
debug: false,
transform: ['reactify']
},
files: {
'public/build/build.js': 'public/js/**/*.jsx'
}
}
},
watch: {
browserify: {
files: ['public/js/**/*.js', 'public/js/**/*.jsx'],
tasks: ['browserify:dev']
},
options: {
nospawn: true
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-env');
grunt.registerTask('default', ['watch']);
grunt.registerTask('build', ['env:build', 'browserify:build']);
};
### Makefile ### Lembre-se que não exige a instalação de pacotes extras
all: dist/app.min.js
build/app.js: src/app.jsx
./node_modules/.bin/browserify -o $@ -t [ reactify --es6 ] $^
dist/app.min.js: build/app.js
./node_modules/.bin/uglifyjs $^ -o $@ --source-map $@.map -c -m
clean: dist/app.min.js build/app.js
rm $^
test:
node_modules/.bin/jest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment