grunt build now also builds the individually minified classes for the custom build configurator

This commit is contained in:
Eric Rowell 2013-06-01 15:41:25 -07:00
parent 5d1a78589a
commit 6d9adad2f5
2 changed files with 86 additions and 61 deletions

View File

@ -1,14 +1,5 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: [
var sourceFiles = [
// core / anim + tween + dd
'src/Global.js',
'src/Util.js',
@ -48,12 +39,22 @@ module.exports = function(grunt) {
'src/filters/Invert.js',
'src/filters/Blur.js',
'src/filters/Mask.js'
],
];
// Project configuration.
var config = {
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
build: {
src: sourceFiles,
dest: 'dist/kinetic-v<%= pkg.version %>.js'
}
},
replace: {
dist: {
dev: {
options: {
variables: {
version: '<%= pkg.version %>',
@ -64,34 +65,59 @@ module.exports = function(grunt) {
},
prefix: '@@'
},
files: [
{
expand: true,
flatten: true,
files: [{
src: ['dist/kinetic-v<%= pkg.version %>.js'],
dest: 'dist/'
}
]
dest: 'dist/kinetic-v<%= pkg.version %>.js'
}]
},
prod: {
options: {
variables: {
version: '<%= pkg.version %>',
},
prefix: '@@'
},
files: [{
src: ['dist/kinetic-Global-v<%= pkg.version %>.min.js'],
dest: 'dist/kinetic-Global-v<%= pkg.version %>.min.js'
}]
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> http://www.kineticjs.com - MIT License https://github.com/ericdrowell/KineticJS/wiki/License*/\n'
banner: '/*! <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> http://www.kineticjs.com by Eric Rowell @ericdrowell - MIT License https://github.com/ericdrowell/KineticJS/wiki/License*/\n'
},
build: {
src: 'dist/kinetic-v<%= pkg.version %>.js',
dest: 'dist/kinetic-v<%= pkg.version %>.min.js'
files: {
'dist/kinetic-v<%= pkg.version %>.min.js': 'dist/kinetic-v<%= pkg.version %>.js'
}
}
});
},
clean: {
build: ['dist/*']
}
};
for (var n=0; n<sourceFiles.length; n++) {
var inputFile = sourceFiles[n];
var className = (inputFile.match(/[-_\w]+[.][\w]+$/i)[0]).replace('.js', '');
var outputFile = 'dist/kinetic-' + className + '-v<%= pkg.version %>.min.js';
config.uglify.build.files[outputFile] = [inputFile];
}
grunt.initConfig(config);
// Load plugins
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
// Tasks
grunt.registerTask('dev', ['concat', 'replace']);
grunt.registerTask('prod', ['concat', 'replace', 'uglify']);
grunt.registerTask('dev', ['clean', 'concat', 'replace:dev']);
grunt.registerTask('full', ['clean', 'concat', 'replace:dev', 'uglify', 'replace:prod']);
};

View File

@ -7,11 +7,10 @@
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-replace": "~0.4.4"
"grunt-replace": "~0.4.4",
"grunt-contrib-clean": "~0.4.1"
},
"readmeFilename": "README.md",
"gitHead": "7b9322c15c08b3ff78f64f5cfd3e9f88850dcadc",
"description": "To build the framework, you need to have Ruby and Rubygems installed. After that, run `gem install thor`, `gem install json_pure`, and `gem install uglifier` to install the dependencies.",
"main": "Gruntfile.js",
"directories": {
"test": "tests"