Last active
August 29, 2015 13:56
-
-
Save rutger1140/9131114 to your computer and use it in GitHub Desktop.
Grunt and bower build scripts for frontend stack of website
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
{ | |
"name": "Project", | |
"version": "0.01", | |
"authors": [ | |
"Rutger Laurman <info@lekkerduidelijk.nl>" | |
], | |
"license": "MIT", | |
"ignore": [ | |
"**/.*", | |
"node_modules", | |
"bower_components", | |
"test", | |
"tests" | |
], | |
"dependencies": { | |
"bootstrap": "~3.1.0", | |
"respond": "~1.4.2", | |
"jquery-backstretch": "~2.0.4", | |
"html5shiv": "~3.7.0", | |
"modernizr": "~2.7.1", | |
"iosslider": "git@github.com:iosscripts/iosslider.git#master", | |
"normalize-css": "~3.0.0", | |
"webfontloader": "~1.5.2" | |
} | |
} |
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
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
banner: '/*! <%= pkg.name %> | <%= pkg.author %> | <%= grunt.template.today("yyyy-mm-dd") %> */\n', | |
usebanner: { | |
build: { | |
options: { | |
position: 'top', | |
banner: '<%= banner %>', | |
linebreak: false | |
}, | |
files: { | |
src: [ 'build/assets/js/all.js', 'build/assets/css/style.css' ] | |
} | |
} | |
}, | |
copy: { | |
build: { | |
cwd: 'source', | |
src: [ | |
'**', | |
'!**/*.less', | |
'!**/css/**', | |
'!**/sketch/**' | |
], | |
dest: 'build', | |
expand: true | |
}, | |
}, | |
clean: { | |
build: { | |
src: [ 'build' ] | |
}, | |
scripts: { | |
src: [ | |
'build/assets/js/**/*.js', | |
'build/assets/js/vendor/**', | |
'!build/assets/js/all.full.js', | |
'!build/assets/js/all.js', | |
'!build/assets/js/oldbrowsers.js' | |
] | |
}, | |
media: { | |
src: [ | |
'build/assets/icons-min/**', | |
'build/assets/icons/*.svg', | |
'build/assets/icons/*.txt', | |
'build/assets/icons/*.html' | |
] | |
} | |
}, | |
less: { | |
build: { | |
options: { | |
paths: ["source/assets/css"], | |
dumpLineNumbers: 'comments', | |
compress: false | |
}, | |
files: [{ | |
src: 'source/assets/css/style.less', | |
dest: 'build/assets/css/style.full.css' | |
}] | |
} | |
}, | |
autoprefixer: { | |
build: { | |
expand: true, | |
cwd: 'build', | |
src: [ '**/*.css' ], | |
dest: 'build' | |
} | |
}, | |
cssmin: { | |
build: { | |
files: { | |
'build/assets/css/style.css': [ 'build/assets/css/style.full.css' ] | |
} | |
} | |
}, | |
concat: { | |
base: { | |
src: [ | |
'bower_components/jquery/jquery.js', | |
'bower_components/jquery-backstretch/jquery.backstretch.js', | |
'source/assets/js/plugins.js', | |
'source/assets/js/main.js', | |
], | |
dest: 'build/assets/js/all.full.js', | |
}, | |
oldbrowsers: { | |
src: [ | |
'bower_components/html5shiv/dist/html5shiv.js', | |
'bower_components/respond/dest/respond.min.js' | |
], | |
dest: 'build/assets/js/oldbrowsers.js' | |
} | |
}, | |
uglify: { | |
build: { | |
options: { | |
report: 'min' | |
}, | |
files: { | |
'build/assets/js/all.js': [ 'build/assets/js/all.full.js' ], | |
'build/assets/js/oldbrowsers.js': [ 'build/assets/js/oldbrowsers.js' ] | |
} | |
} | |
}, | |
imagemin: { | |
build: { | |
files: [{ | |
expand: true, | |
cwd: 'source/assets/img/', | |
src: ['**/*.{png,jpg,gif}'], | |
dest: 'build/assets/img/' | |
}] | |
} | |
}, | |
svgmin: { | |
options: { | |
plugins: [ | |
{ removeViewBox: false }, | |
{ removeUselessStrokeAndFill: false } | |
] | |
}, | |
build: { | |
files: [{ | |
expand: true, | |
cwd: 'source/assets/img', | |
src: ['**/*.svg'], | |
dest: 'build/assets/img/' | |
}] | |
}, | |
buildIcons: { | |
files: [{ | |
expand: true, | |
cwd: 'source/assets/icons', | |
src: ['**/*.svg'], | |
dest: 'build/assets/icons-min/' | |
}] | |
} | |
}, | |
grunticon: { | |
build: { | |
files: [{ | |
expand: true, | |
cwd: 'build/assets/icons-min', | |
src: ['*.svg'], | |
dest: 'build/assets/icons/' | |
}], | |
options: { | |
datasvgcss: 'icons.css', | |
datapngcss: 'icons-png-notused.css.txt', | |
urlpngcss: 'fallback.css', | |
cssprefix: '.ico--' | |
} | |
} | |
}, | |
watch: { | |
scripts: { | |
files: ['source/**/*.js'], | |
tasks: ['scripts'], | |
}, | |
stylesheets: { | |
files: ['source/**/*.less'], //, 'source/**/module/*.less', 'source/**/layout/*.less'], | |
tasks: ['stylesheets'], | |
}, | |
copy: { | |
files: ['source/**', '!source/**/*.js', '!source/**/*.less'], | |
tasks: ['copy'] | |
} | |
}, | |
connect: { | |
server: { | |
options: { | |
port: 4000, | |
base: 'build', | |
hostname: '*' | |
} | |
} | |
}, | |
notify: { | |
stylesheets: { | |
options: { | |
message: "Stylesheets done" | |
} | |
}, | |
scripts: { | |
options: { | |
message: "Scripts done!" | |
} | |
}, | |
media: { | |
options: { | |
message: "Media done!" | |
} | |
}, | |
build: { | |
options: { | |
message: "Build done!" | |
} | |
}, | |
}, | |
}); | |
grunt.loadNpmTasks('grunt-autoprefixer'); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-banner'); | |
grunt.loadNpmTasks('grunt-notify'); | |
grunt.loadNpmTasks('grunt-svgmin'); | |
grunt.loadNpmTasks('grunt-grunticon'); | |
grunt.registerTask( | |
'default', | |
'Watches the project for changes, automatically builds them and runs a server.', | |
[ 'build', 'connect', 'watch' ] | |
); | |
grunt.registerTask( | |
'stylesheets', | |
'Compile all stylesheets', | |
[ | |
'less', | |
'autoprefixer', | |
'cssmin', | |
'notify:stylesheets' | |
] | |
); | |
grunt.registerTask( | |
'scripts', | |
'Compile all javascripts', | |
[ | |
'concat', | |
'uglify', | |
'clean:scripts', | |
'notify:scripts' | |
] | |
); | |
grunt.registerTask( | |
'media', | |
'Minify all media images and SVG', | |
[ | |
'imagemin', | |
'svgmin', | |
'grunticon', | |
'clean:media', | |
'notify:media' | |
] | |
); | |
grunt.registerTask( | |
'build', | |
'Compile all assets from source into build', | |
[ | |
'clean:build', | |
'copy', | |
'stylesheets', | |
'scripts', | |
'media', | |
'usebanner', | |
'notify:build' | |
] | |
); | |
}; |
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
{ | |
"name": "Project", | |
"version": "0.0.1", | |
"description": "Build tasks for frontend stack", | |
"author": "Rutger Laurman - lekkerduidelijk.nl", | |
"devDependencies": { | |
"grunt": "~0.4.2", | |
"grunt-autoprefixer": "~0.7.1", | |
"grunt-contrib-cssmin": "~0.8.0", | |
"grunt-contrib-clean": "~0.5.0", | |
"grunt-contrib-concat": "~0.3.0", | |
"grunt-contrib-copy": "~0.5.0", | |
"grunt-contrib-imagemin": "~0.4.0", | |
"grunt-contrib-jshint": "~0.8.0", | |
"grunt-contrib-less": "~0.8.3", | |
"grunt-contrib-uglify": "~0.2.7", | |
"grunt-contrib-watch": "~0.5.3", | |
"grunt-banner": "~0.2.0", | |
"grunt-grunticon": "~1.0.0", | |
"grunt-notify": "~0.2.17", | |
"grunt-svgmin": "~0.3.1", | |
"grunt-contrib-connect": "~0.6.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment