Created
March 30, 2016 10:06
-
-
Save hotab/46f541f2c449363d9253d47482cd82af to your computer and use it in GitHub Desktop.
Gruntfile that is used in lunapps.com building process
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
/** | |
* lunapps.com's Gruntfile | |
*/ | |
module.exports = function (grunt) { | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
grunt.loadNpmTasks('grunt-contrib-jade'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-compress'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-sitemap-xml'); | |
try { | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
} | |
catch (e) { | |
//We are running on the server. Connect and watch won't be available here! | |
} | |
grunt.initConfig({ | |
clean: { | |
'compile-prod': ['build/'] | |
}, | |
less: { | |
'compile-prod': { | |
files: { | |
'build/style.css': 'style/style.less' | |
} | |
}, | |
'compile-blog': { | |
files: { | |
'build/blog.css': 'style/blog.less' | |
} | |
} | |
}, | |
jade: { | |
'compile-prod': { | |
files: { | |
'build/index.html': ['jade/index.jade'], | |
'build/404.html': ['jade/404.jade'], | |
'build/portfolio/index.html': ['jade/portfolio.jade'], | |
'build/services/index.html': ['jade/services.jade'], | |
'build/about-us/index.html': ['jade/about-us.jade'], | |
'build/contact-us/index.html': ['jade/contact-us.jade'], | |
'build/portfolio/text-a-letter/index.html': ['jade/projects/text-a-letter.jade'], | |
'build/portfolio/bidit/index.html': ['jade/projects/bidit.jade'] | |
} | |
} | |
}, | |
cssmin: { | |
'compile-prod': { | |
files: [{ | |
expand: true, | |
cwd: 'build', | |
src: ['*.css', '!*.min.css'], | |
dest: 'build', | |
ext: '.css', | |
extDot: 'last' | |
}, { | |
expand: true, | |
cwd: 'build/style/lib', | |
src: ['*.css', '!*.min.css'], | |
dest: 'build/style/lib', | |
ext: '.css', | |
extDot: 'last' | |
}] | |
} | |
}, | |
uglify: { | |
options: { | |
mangle: true, | |
compress: { | |
drop_console: true, | |
dead_code: true, | |
properties: true, | |
drop_debugger: true, | |
conditionals: true, | |
comparisons: true, | |
booleans: true, | |
loops: true, | |
unused: true, | |
if_return: true, | |
join_vars: true, | |
keep_fargs: true, | |
keep_fnames: true | |
} | |
}, | |
'compile-prod': { | |
files: [{ | |
expand: true, | |
cwd: 'js', | |
src: ['**/*.js', '!*/*.min.js'], | |
dest: 'build/js', | |
ext: '.js', | |
extDot: 'last' | |
}] | |
} | |
}, | |
copy: { | |
'compile-prod': { | |
files: [ | |
{ | |
expand: true, | |
src: ['fonts/**', 'img/**', 'video/**','files/**', 'style/lib/*.css', 'style/lib/*.png', 'js/lib/*.js','sitemap.xml', 'crossdomain.xml', 'robots.txt'], | |
dest: 'build' | |
}, | |
{ | |
expand: true, | |
src: ['style/lib/*.css', 'style/'], | |
dest: 'build' | |
} | |
] | |
}, | |
'script-develop': { | |
files: [ | |
{ | |
expand: true, | |
src: ['js/*.js'], | |
dest: 'build' | |
} | |
] | |
} | |
}, | |
compress: { | |
'compile-prod': { | |
options: { | |
mode: 'gzip', | |
level: 9 | |
}, | |
expand: true, | |
src: ['build/**/*.js', 'build/**/*.css', 'build/**/*.html', 'build/**/*.svg', 'build/**/*.xml', 'build/**/*.txt', 'build/**/*.sketch'], | |
extDot: 'last', | |
rename: function (dest, src) { | |
return src + '.gz'; | |
} | |
} | |
}, | |
connect: { | |
server: { | |
options: { | |
livereload: true, | |
base: 'build' | |
} | |
} | |
}, | |
watch: { | |
options: { | |
livereload: true | |
}, | |
styles: { | |
files: ['style/**/*.less'], | |
tasks: ['less:compile-prod'], | |
options: { | |
spawn: false | |
} | |
}, | |
jade: { | |
files: ['**/*.jade', '**/*.svg'], | |
tasks: ['jade:compile-prod'], | |
options: { | |
spawn: false | |
} | |
}, | |
scripts: { | |
files: ['js/*.js'], | |
tasks: ['copy:script-develop'], | |
options: { | |
spawn: false | |
} | |
} | |
}, | |
sitemap_xml: { | |
custom_options: { | |
options: { | |
changefreq: 'weekly', | |
siteRoot: 'https://lunapps.com/', | |
priority: '1' | |
}, | |
files: [ | |
{ | |
cwd: 'build/', | |
src: [ | |
'**/*.html', | |
'!**/404.html' | |
], | |
dest: 'build/landing.xml' | |
} | |
] | |
} | |
} | |
}); | |
grunt.registerTask('default', [ | |
'clean:compile-prod', | |
'less:compile-prod', | |
'less:compile-blog', | |
'jade:compile-prod', | |
'copy:compile-prod', | |
'copy:script-develop', | |
'connect:server', | |
'watch']); | |
grunt.registerTask('compile-prod', [ | |
'clean:compile-prod', | |
'less:compile-prod', | |
'jade:compile-prod', | |
'copy:compile-prod', | |
'cssmin:compile-prod', | |
'uglify:compile-prod', | |
'sitemap_xml', | |
'compress:compile-prod']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment