Build mobile apps with simple HTML, CSS, and JS components. http://goratchet.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
5.5 KiB

/* ----------------------------------
* Ratchet's Gruntfile
* Licensed under The MIT License
* http://opensource.org/licenses/MIT
* ---------------------------------- */
module.exports = function(grunt) {
'use strict';
// Force use of Unix newlines
grunt.util.linefeed = '\n';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Metadata.
meta: {
distPath: 'dist/',
docsPath: 'docs/dist/',
docsAssetsPath: 'docs/assets/'
},
banner: '/*!\n' +
11 years ago
' * =====================================================\n' +
' * Ratchet v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
11 years ago
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= pkg.license %>.\n' +
11 years ago
' *\n' +
' * v<%= pkg.version %> designed by @connors.\n' +
11 years ago
' * =====================================================\n' +
' */\n',
concat: {
ratchet: {
options: {
banner: '<%= banner %>'
},
src: [
'js/modals.js',
'js/popovers.js',
'js/push.js',
'js/segmented-controllers.js',
'js/sliders.js',
'js/toggles.js'
],
dest: '<%= meta.distPath %>js/<%= pkg.name %>.js'
},
docs: {
src: '<%= meta.distPath %>js/<%= pkg.name %>.js',
dest: '<%= meta.docsPath %>js/<%= pkg.name %>.js'
}
},
11 years ago
sass: {
11 years ago
options: {
banner: '<%= banner %>',
style: 'expanded',
unixNewlines: true
11 years ago
},
dist: {
files: {
'<%= meta.distPath %>css/<%= pkg.name %>.css': 'sass/ratchet.scss',
'<%= meta.distPath %>css/<%= pkg.name %>-theme-ios.css': 'sass/theme-ios.scss',
'<%= meta.distPath %>css/<%= pkg.name %>-theme-android.css': 'sass/theme-android.scss',
'<%= meta.docsAssetsPath %>css/docs.css': 'sass/docs.scss'
}
11 years ago
}
},
copy: {
fonts: {
expand: true,
src: 'fonts/*',
dest: 'dist/'
},
docs: {
expand: true,
cwd: 'dist',
src: [
'**/*'
],
dest: 'docs/dist'
}
},
cssmin: {
options: {
banner: '', // set to empty; see bellow
keepSpecialComments: '*', // set to '*' because we already add the banner in sass
noAdvanced: true, // disable advanced optimizations since it causes many issues
report: 'min'
},
ratchet: {
src: '<%= meta.distPath %>css/<%= pkg.name %>.css',
dest: '<%= meta.distPath %>css/<%= pkg.name %>.min.css'
},
theme: {
files: {
'<%= meta.distPath %>css/<%= pkg.name %>-theme-ios.min.css': '<%= meta.distPath %>css/<%= pkg.name %>-theme-ios.css',
'<%= meta.distPath %>css/<%= pkg.name %>-theme-android.min.css' : '<%= meta.distPath %>css/<%= pkg.name %>-theme-android.css'
}
},
docs: {
src: [
'<%= meta.docsAssetsPath %>css/docs.css',
'<%= meta.docsAssetsPath %>css/pygments-manni.css'
],
dest: '<%= meta.docsAssetsPath %>css/docs.min.css'
}
},
uglify: {
options: {
banner: '<%= banner %>',
compress: true,
mangle: true,
preserveComments: false,
report: 'min'
},
ratchet: {
src: '<%= meta.distPath %>js/<%= pkg.name %>.js',
dest: '<%= meta.distPath %>js/<%= pkg.name %>.min.js'
},
docs: {
src: [
'<%= meta.docsAssetsPath %>js/docs.js',
'<%= meta.docsAssetsPath %>js/fingerblast.js'
],
dest: '<%= meta.docsAssetsPath %>js/docs.min.js'
}
},
watch: {
11 years ago
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.',
'Bad value apple-mobile-web-app-status-bar-style for attribute name on element meta: Keyword apple-mobile-web-app-status-bar-style is not registered.',
'Bad value X-UA-Compatible for attribute http-equiv on element meta.',
'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
}
}
});
// Load the plugins
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
// Default task(s).
grunt.registerTask('dist-css', ['sass', 'cssmin']);
grunt.registerTask('dist-js', ['concat', 'uglify']);
grunt.registerTask('dist', ['dist-css', 'dist-js', 'copy']);
grunt.registerTask('validate-html', ['jekyll', 'validation']);
grunt.registerTask('default', ['dist']);
grunt.registerTask('build', ['dist']);
grunt.registerTask('test', ['dist', 'validate-html']);
// 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');
11 years ago
};