Last active
March 1, 2019 18:52
-
-
Save bunlongheng/cdc0fa623e09edc489a4 to your computer and use it in GitHub Desktop.
I used this build system for my site : www.bunlongheng.com
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
/* | |
Grunt installation: | |
------------------- | |
npm install -g grunt-cli | |
npm install -g grunt-init | |
npm init (creates a `package.json` file) | |
Project Dependencies: | |
--------------------- | |
npm install - S grunt--save - dev | |
npm install grunt-contrib-concat --save-dev | |
npm install grunt-contrib-uglify --save-dev | |
npm install grunt-contrib-cssmin --save-dev | |
npm install grunt-contrib-clean --save-dev | |
npm install grunt-contrib-watch --save-dev | |
npm install grunt-contrib-compress --save-dev | |
npm install grunt-contrib-imagemin --save-dev | |
npm install --save imagemin-mozjpeg | |
hold | |
---- | |
npm install grunt-uncss --save-dev | |
npm install grunt-processhtml --save-dev | |
Example Usage: | |
-------------- | |
grunt -v | |
grunt release -v | |
*/ | |
module.exports = function(grunt) { | |
"use strict"; | |
var mozjpeg = require('imagemin-mozjpeg'); | |
grunt.initConfig({ | |
// ----------------------------------------------------------------------------[ clean ] | |
clean: { | |
js: { | |
src: ["dist/js"] | |
}, | |
css: { | |
src: ["dist/css"] | |
}, | |
php: { | |
src: ["dist/php"] | |
}, | |
img: { | |
src: ["dist/img"] | |
}, | |
dist: { | |
src: ["dist"] | |
} | |
}, | |
// ----------------------------------------------------------------------------[ concat ] | |
concat: { | |
js: { | |
src: [ | |
'js/jquery-1.10.2.min.js', | |
'js/bootstrap.min.js', | |
'js/jquery.easypiechart.min.js', | |
'js/jquery.isotope.min.js', | |
'js/jquery.magnific-popup.min.js', | |
'js/waypoints.min.js', | |
'js/respond.min.js', | |
'js/jquery.vegas.min.js', | |
'js/modernizr-2.6.2.min.js', | |
'js/jquery.nav.js', | |
'js/html5shiv.js', | |
'js/jquery.scrollTo.js', | |
'js/jquery.sticky.js', | |
'js/jquery.validate.js', | |
'js/main.js', | |
], | |
dest: 'dist/js/concat.js' | |
}, | |
css: { | |
src: [ | |
'css/bootstrap.min.css', | |
'css/magnific-popup.css', | |
'css/main.css', | |
], | |
dest: 'dist/css/concat.css' | |
}, | |
php: { | |
src: [ | |
'2015/layouts/header.php', | |
'2015/layouts/ie.php', | |
'2015/layouts/meta.php', | |
'2015/layouts/link.php', | |
'2015/layouts/style.php', | |
'2015/layouts/ie9.php', | |
'2015/layouts/nav-bar.php', | |
'2015/layouts/welcome-sign.php', | |
'2015/layouts/profile.php', | |
'2015/layouts/skill.php', | |
'2015/layouts/education.php', | |
'2015/layouts/experience.php', | |
'2015/layouts/portfolio.php', | |
'2015/layouts/contact.php', | |
'2015/layouts/print.php', | |
'2015/layouts/script.php' | |
], | |
dest: 'dist/php/concat.php' | |
} | |
}, | |
// ----------------------------------------------------------------------------[ uglify ] | |
uglify: { | |
js: { | |
files: { | |
'dist/js/scripts.min.js': ['dist/js/concat.js'] | |
} | |
} | |
}, | |
// ----------------------------------------------------------------------------[ htmlmin ] | |
htmlmin: { | |
dist: { | |
options: { | |
removeComments: true, | |
collapseWhitespace: true | |
}, | |
files: { | |
'index.php': 'dist/php/concat.php', | |
} | |
} | |
}, | |
// ----------------------------------------------------------------------------[ watch ] | |
watch: { | |
js: { | |
files: ['js/*.js'], | |
tasks: ['clean:js', 'concat:js', 'uglify:js'] | |
}, | |
css: { | |
files: ['css/*.css'], | |
tasks: ['clean:css', 'concat:css', 'cssmin:style'] | |
} | |
}, | |
// ----------------------------------------------------------------------------[ uncss ] | |
uncss: { | |
dist: { | |
options: { | |
ignore : [/expanded/,/js/,/wp-/,/align/,/admin-bar/], | |
stylesheets : ['css/main.min.css'], | |
ignoreSheets : [/fonts.googleapis/], | |
urls : [], | |
}, | |
files: { | |
'css/main.min.css': ['index.php'] | |
} | |
} | |
}, | |
// ----------------------------------------------------------------------------[ processhtml ] | |
processhtml: { | |
dist: { | |
files: { | |
'index.html': ['index.html'] | |
} | |
} | |
}, | |
// ----------------------------------------------------------------------------[ cssmin ] | |
cssmin: { | |
style: { | |
files: { | |
'dist/css/styles.min.css': ['dist/css/concat.css'] | |
} | |
}, | |
color: { | |
files: [{ | |
expand: true, | |
cwd: 'css/colors', | |
src: ['*.css', '!*.min.css'], | |
dest: 'dist/css/colors', | |
ext: '.min.css' | |
}] | |
} | |
}, | |
// ----------------------------------------------------------------------------[ compress ] | |
compress: { | |
options: { mode: 'gzip' }, | |
main: { | |
files: [ | |
{ src: ['dist/js/scripts.min.js'], dest: 'dist/js/scripts.min.gz.js'}, | |
{ src: ['dist/css/styles.min.css'], dest: 'dist/css/styles.min.gz.css'} | |
], | |
}, | |
}, | |
// ----------------------------------------------------------------------------[ imagemin ] | |
imagemin: { | |
dynamic: { | |
options: { | |
optimizationLevel: 3, | |
svgoPlugins: [{ removeViewBox: false }], | |
use: [mozjpeg()] | |
}, | |
files: [{ | |
expand: true, // Enable dynamic expansion | |
cwd: 'img', // Src matches are relative to this path | |
src: ['**/*.{png,jpg,gif,ico}'], // Actual patterns to match | |
dest: 'dist/img' // Destination path prefix | |
}] | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-htmlmin'); | |
grunt.loadNpmTasks('grunt-contrib-compress'); | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
// Hold | |
// grunt.loadNpmTasks('grunt-uncss'); | |
// grunt.loadNpmTasks('grunt-processhtml'); | |
// grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.registerTask('default', [ | |
// 'clean:dist', | |
// 'imagemin', | |
'clean:js', | |
'clean:css', | |
'clean:php', | |
'concat', | |
'uglify', | |
'cssmin', | |
'htmlmin', | |
'compress' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment