ratchet/Gruntfile.js

162 строки
4.2 KiB
JavaScript
Исходник Обычный вид История

2014-02-26 03:03:04 +04:00
/* ----------------------------------
* Ratchet's Gruntfile
* Licensed under The MIT License
* http://opensource.org/licenses/MIT
* ---------------------------------- */
2013-09-11 22:01:13 +04:00
module.exports = function(grunt) {
'use strict';
// Force use of Unix newlines
grunt.util.linefeed = '\n';
2013-09-11 22:01:13 +04:00
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Metadata.
meta: {
2014-02-16 23:09:47 +04:00
distPath: 'dist/',
docsPath: 'docs/dist/',
docsAssetsPath: 'docs/assets/'
},
2014-02-26 14:07:55 +04:00
banner: '/*!\n' +
2013-10-12 23:11:34 +04:00
' * =====================================================\n' +
' * Ratchet v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
2013-10-12 23:11:34 +04:00
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= pkg.license %>.\n' +
2013-10-12 23:11:34 +04:00
' *\n' +
' * v<%= pkg.version %> designed by @connors.\n' +
2013-10-12 23:11:34 +04:00
' * =====================================================\n' +
' */\n',
2014-02-26 14:07:55 +04:00
2013-09-12 01:58:52 +04:00
concat: {
ratchet: {
2014-02-26 03:33:08 +04:00
options: {
banner: '<%= banner %>'
},
2013-09-12 01:58:52 +04:00
src: [
2014-02-16 23:09:47 +04:00
'js/modals.js',
'js/popovers.js',
'js/push.js',
'js/segmented-controllers.js',
'js/sliders.js',
'js/toggles.js'
2013-09-12 01:58:52 +04:00
],
dest: '<%= meta.distPath %><%= pkg.name %>.js'
2014-02-16 23:09:47 +04:00
},
docs: {
src: '<%= meta.distPath %><%= pkg.name %>.js',
dest: '<%= meta.docsPath %><%= pkg.name %>.js'
2013-09-11 22:01:13 +04:00
}
2013-09-12 01:58:52 +04:00
},
2014-02-26 14:07:55 +04:00
2013-09-11 23:53:07 +04:00
sass: {
2013-10-12 23:11:34 +04:00
options: {
banner: '<%= banner %>',
2014-02-26 03:33:08 +04:00
style: 'expanded'
2013-10-12 23:11:34 +04:00
},
dist: {
files: {
2014-02-16 23:09:47 +04:00
'<%= meta.distPath %><%= pkg.name %>.css': 'sass/ratchet.scss',
2014-02-25 05:19:20 +04:00
'<%= meta.distPath %><%= pkg.name %>-theme-ios.css': 'sass/theme-ios.scss',
'<%= meta.distPath %><%= pkg.name %>-theme-android.css': 'sass/theme-android.scss',
2014-02-25 04:31:41 +04:00
'<%= meta.docsAssetsPath %>css/docs.css': 'sass/docs.scss'
}
2013-10-12 23:11:34 +04:00
}
},
2014-02-25 04:31:41 +04:00
copy: {
docs: {
expand: true,
cwd: 'dist',
src: [
2014-02-27 23:16:07 +04:00
'**/*'
2014-02-25 04:31:41 +04:00
],
dest: 'docs/dist'
}
},
2014-02-26 03:33:08 +04:00
cssmin: {
2014-02-27 08:44:52 +04:00
minify: {
options: {
banner: '', // set to empty ; see bellow
keepSpecialComments: '*', // set to '*' because we already add the banner in sass
report: 'min'
},
2014-02-26 03:33:08 +04:00
files: {
2014-02-27 08:44:52 +04:00
'dist/<%= pkg.name %>.min.css': 'dist/<%= pkg.name %>.css'
2014-02-26 03:33:08 +04:00
}
}
},
uglify: {
options: {
2014-02-27 08:40:57 +04:00
banner: '<%= banner %>',
2014-02-26 03:33:08 +04:00
report: 'min'
},
ratchet: {
src: 'dist/<%= pkg.name %>.js',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
watch: {
2013-10-12 23:11:34 +04:00
scripts: {
files: [
'<%= meta.srcPath %>/**/*.scss'
],
tasks: ['sass']
}
},
jekyll: {
docs: {}
},
validation: {
options: {
charset: 'utf-8',
doctype: 'HTML5',
failHard: true,
reset: true,
relaxerror: [
'Bad value apple-mobile-web-app-title for attribute name on element meta: Keyword apple-mobile-web-app-title is not registered.',
'Attribute ontouchstart not allowed on element body at this point.'
]
},
files: {
src: '_site/**/*.html'
}
},
sed: {
versionNumber: {
pattern: (function () {
var old = grunt.option('oldver');
return old ? RegExp.quote(old) : old;
})(),
replacement: grunt.option('newver'),
recursive: true
}
2013-09-11 22:01:13 +04:00
}
});
2013-09-14 02:40:18 +04:00
// Load the plugins
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
2013-09-11 22:01:13 +04:00
// Default task(s).
2014-02-26 03:33:08 +04:00
grunt.registerTask('dist-css', ['sass', 'cssmin']);
grunt.registerTask('dist-js', ['concat', 'uglify']);
2014-02-27 08:37:01 +04:00
grunt.registerTask('dist', ['dist-css', 'dist-js', 'copy']);
grunt.registerTask('validate-html', ['jekyll', 'validation']);
2014-02-26 03:33:08 +04:00
grunt.registerTask('default', ['dist']);
grunt.registerTask('build', ['dist']);
// Version numbering task.
// grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
// This can be overzealous, so its changes should always be manually reviewed!
grunt.registerTask('change-version-number', 'sed');
2013-10-12 23:11:34 +04:00
};