Last active
March 23, 2016 23:02
-
-
Save teledirigido/ed23cbb3a0221216c78a to your computer and use it in GitHub Desktop.
Grunt file configuration example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
GRUNTFILE JS WORKING EXAMPLE | |
---------------------------- | |
- Babel | |
- Uglify | |
- Browser Sync | |
- Sass | |
- Watch | |
- Grunt Tasks | |
- Babel ES2015 | |
Note: It might not be working working example. | |
Your package.json should look like this: | |
{ | |
"name": "grunt-reload", | |
"version": "1.0.0", | |
"devDependencies": { | |
"grunt": "~0.4.3", | |
"grunt-babel": "^6.0.0", | |
"grunt-contrib-uglify": "latest", | |
"grunt-browser-sync": "~2.0.0", | |
"grunt-contrib-sass": "^0.7.3", | |
"grunt-contrib-watch": "~0.6.0", | |
"load-grunt-tasks": "^3.4.0", | |
"babel-preset-es2015": "^6.3.13" | |
} | |
} | |
*/ | |
module.exports = function(grunt) { | |
require("load-grunt-tasks")(grunt); | |
// Configure Grunt | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
my_target: { | |
files: { | |
'themes/wp-theme/js/min/scripts.min.js': [ | |
'themes/wp-theme/js/myfile1.js', | |
'themes/wp-theme/js/myfile2.js', | |
] | |
} | |
} | |
}, | |
browserSync: { | |
dev: { | |
bsFiles: { | |
src : [ | |
'themes/wp-theme/*.css', | |
'themes/wp-theme/*.php', | |
'themes/wp-theme/**/*.php', | |
'themes/wp-theme/js/*.js', | |
'themes/wp-theme/js/**/*.js', | |
] | |
}, | |
options: { | |
watchTask: true, | |
proxy: "http://blacksheepdesign.dev/theme/site" | |
} | |
} | |
}, | |
sass: { | |
dist: { | |
options: { | |
style: 'expanded', | |
sourcemap: false | |
}, | |
files: { | |
'themes/wp-theme/style.css' : 'themes/wp-theme/style.scss', | |
} | |
} | |
}, | |
// grunt-watch will monitor the projects files | |
// https://github.com/gruntjs/grunt-contrib-watch | |
watch: { | |
template: { | |
files: ['themes/wp-theme/*.php', 'themes/wp-theme/**/*.php' ], | |
options: { | |
livereload: true | |
} | |
}, | |
css: { | |
files: ['themes/wp-theme/*.scss','themes/wp-theme/**/*.scss'], | |
tasks: ['sass'] | |
}, | |
scripts: { | |
files: ['themes/wp-theme/js/*.js','themes/wp-theme/js/src/*.js'], | |
tasks: ['uglify'], | |
options: { | |
livereload: true | |
} | |
} | |
}, | |
}); | |
grunt.loadNpmTasks('grunt-browser-sync'); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
// Creates the `server` task | |
grunt.registerTask('site', [ | |
'browserSync', | |
'uglify', | |
'sass', | |
'watch', | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment