123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- /*global module:false*/
- module.exports = function(grunt) {
- var packageJSON = grunt.file.readJSON('package.json');
- var bumpFiles = ["package.json", "bower.json", "composer.json"];
- var commitFiles = bumpFiles.concat(["./dist/*"]);
- // Project configuration.
- grunt.initConfig({
- // Metadata
- pkg: packageJSON,
- // Task configuration.
- header: {
- dist: {
- options: {
- text: "/*! =======================================================\n VERSION <%= pkg.version %> \n========================================================= */"
- },
- files: {
- '<%= pkg.gruntConfig.dist.js %>': '<%= pkg.gruntConfig.temp.js %>',
- '<%= pkg.gruntConfig.dist.jsMin %>': '<%= pkg.gruntConfig.temp.jsMin %>',
- '<%= pkg.gruntConfig.dist.css %>': '<%= pkg.gruntConfig.temp.css %>',
- '<%= pkg.gruntConfig.dist.cssMin %>': '<%= pkg.gruntConfig.temp.cssMin %>'
- }
- }
- },
- uglify: {
- options: {
- preserveComments: 'some'
- },
- dist: {
- src: '<%= pkg.gruntConfig.temp.js %>',
- dest: '<%= pkg.gruntConfig.temp.jsMin %>'
- }
- },
- babel: {
- options: {
- presets: ['es2015']
- },
- dist: {
- src: '<%= pkg.gruntConfig.js.slider %>',
- dest: '<%= pkg.gruntConfig.temp.js %>'
- }
- },
- jshint: {
- ignore_warning: {
- options: {
- '-W099': true
- },
- src: '<%= pkg.gruntConfig.js.slider %>'
- },
- options: {
- esnext: true,
- curly: true,
- eqeqeq: true,
- immed: true,
- latedef: false,
- newcap: true,
- noarg: true,
- sub: true,
- undef: true,
- unused: true,
- boss: true,
- eqnull: true,
- browser: true,
- globals: {
- $ : true,
- Modernizr : true,
- console: true,
- define: true,
- module: true,
- require: true
- },
- "-W099": true
- },
- gruntfile: {
- src: 'Gruntfile.js'
- },
- js: {
- src: '<%= pkg.gruntConfig.js.slider %>'
- },
- spec : {
- src: '<%= pkg.gruntConfig.spec %>',
- options : {
- globals : {
- document: true,
- console: false,
- Slider: false,
- $: false,
- jQuery: false,
- _: false,
- _V_: false,
- afterEach: false,
- beforeEach: false,
- confirm: false,
- context: false,
- describe: false,
- expect: false,
- it: false,
- jasmine: false,
- JSHINT: false,
- mostRecentAjaxRequest: false,
- qq: false,
- runs: false,
- spyOn: false,
- spyOnEvent: false,
- waitsFor: false,
- xdescribe: false
- }
- }
- }
- },
- sasslint: {
- options: {
- configFile: './.sass-lint.yml',
- },
- target: ['./src/sass/**/*.scss']
- },
- lesslint: {
- src: ['./src/less/bootstrap-slider.less']
- },
- jasmine : {
- src : '<%= pkg.gruntConfig.temp.js %>',
- options : {
- specs : '<%= pkg.gruntConfig.spec %>',
- vendor : ['<%= pkg.gruntConfig.js.jquery %>', '<%= pkg.gruntConfig.js.bindPolyfill %>'],
- styles : ['<%= pkg.gruntConfig.css.bootstrap %>', '<%= pkg.gruntConfig.temp.css %>'],
- template : '<%= pkg.gruntConfig.tpl.SpecRunner %>'
- }
- },
- template : {
- 'generate-index-page' : {
- options : {
- data : {
- js : {
- highlightjs: '<%= pkg.gruntConfig.js.highlightjs %>',
- modernizr : '<%= pkg.gruntConfig.js.modernizr %>',
- jquery : '<%= pkg.gruntConfig.js.jquery %>',
- slider : '<%= pkg.gruntConfig.temp.js %>'
- },
- css : {
- highlightjs: '<%= pkg.gruntConfig.css.highlightjs %>',
- bootstrap : '<%= pkg.gruntConfig.css.bootstrap %>',
- slider : '<%= pkg.gruntConfig.temp.css %>'
- }
- }
- },
- files : {
- 'index.html' : ['<%= pkg.gruntConfig.tpl.index %>']
- }
- },
- 'generate-gh-pages' : {
- options : {
- data : {
- js : {
- highlightjs: '<%= pkg.gruntConfig.js.highlightjs %>',
- modernizr : '<%= pkg.gruntConfig.js.modernizr %>',
- jquery : '<%= pkg.gruntConfig.js.jquery %>',
- slider : 'js/bootstrap-slider.js'
- },
- css : {
- highlightjs: '<%= pkg.gruntConfig.css.highlightjs %>',
- bootstrap : 'css/bootstrap.min.css',
- slider : 'css/bootstrap-slider.css'
- }
- }
- },
- files : {
- 'index.html' : ['<%= pkg.gruntConfig.tpl.index %>']
- }
- }
- },
- watch: {
- options: {
- livereload: true
- },
- js: {
- files: '<%= pkg.gruntConfig.js.slider %>',
- tasks: ['jshint:js', 'babel', 'jasmine']
- },
- gruntfile: {
- files: '<%= jshint.gruntfile %>',
- tasks: ['jshint:gruntfile']
- },
- spec: {
- files: '<%= pkg.gruntConfig.spec %>',
- tasks: ['jshint:spec', 'jasmine:src']
- },
- css: {
- files: [
- '<%= pkg.gruntConfig.less.slider %>',
- '<%= pkg.gruntConfig.less.rules %>',
- '<%= pkg.gruntConfig.less.variables %>'
- ],
- tasks: ['less:development']
- },
- index: {
- files: '<%= pkg.gruntConfig.tpl.index %>',
- tasks: ['template:generate-index-page']
- }
- },
- connect: {
- server: {
- options: {
- port: "<%= pkg.gruntConfig.devPort %>"
- }
- }
- },
- open : {
- development : {
- path: 'http://localhost:<%= connect.server.options.port %>'
- }
- },
- less: {
- options: {
- paths: ["bower_components/bootstrap/less"]
- },
- development: {
- files: {
- '<%= pkg.gruntConfig.temp.css %>': '<%= pkg.gruntConfig.less.slider %>'
- }
- },
- production: {
- files: {
- '<%= pkg.gruntConfig.temp.css %>': '<%= pkg.gruntConfig.less.slider %>',
- }
- },
- "production-min": {
- options: {
- yuicompress: true
- },
- files: {
- '<%= pkg.gruntConfig.temp.cssMin %>': '<%= pkg.gruntConfig.less.slider %>'
- }
- }
- },
- clean: {
- dist: ["dist"],
- temp: ["temp"]
- },
- bump: {
- options: {
- files: bumpFiles,
- updateConfigs: [],
- commit: true,
- commitMessage: 'Release v%VERSION%',
- commitFiles: commitFiles,
- createTag: true,
- tagName: 'v%VERSION%',
- tagMessage: 'Version %VERSION%',
- push: false,
- pushTo: 'origin'
- }
- }
- });
- // These plugins provide necessary tasks.
- grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-contrib-jasmine');
- grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-contrib-connect');
- grunt.loadNpmTasks('grunt-contrib-clean');
- grunt.loadNpmTasks('grunt-contrib-less');
- grunt.loadNpmTasks('grunt-open');
- grunt.loadNpmTasks('grunt-template');
- grunt.loadNpmTasks('grunt-header');
- grunt.loadNpmTasks('grunt-bump');
- grunt.loadNpmTasks('grunt-babel');
- grunt.loadNpmTasks('grunt-sass-lint');
- grunt.loadNpmTasks('grunt-lesslint');
- // Create custom tasks
- grunt.registerTask('append-header', ['header', 'clean:temp']);
- grunt.registerTask('lint', [
- 'jshint',
- 'lesslint',
- 'sasslint'
- ]);
- grunt.registerTask('test', [
- 'babel',
- 'less:development',
- 'jasmine',
- 'clean:temp'
- ]);
- grunt.registerTask('build', [
- 'less:development',
- 'test',
- 'template:generate-index-page'
- ]);
- grunt.registerTask('build-gh-pages', [
- 'less:development',
- 'babel',
- 'template:generate-gh-pages'
- ]);
- grunt.registerTask('dist', [
- 'clean:dist',
- 'less:production',
- 'less:production-min',
- 'babel',
- 'uglify',
- 'append-header'
- ]);
- grunt.registerTask('development', [
- 'less:development',
- 'babel',
- 'template:generate-index-page',
- 'connect',
- 'open:development',
- 'watch'
- ]);
- grunt.registerTask('production', ['dist']);
- grunt.registerTask('dev', 'development');
- grunt.registerTask('prod', 'production');
- grunt.registerTask('default', ['build']);
- }; // End of module
|