Commit f5225f03 authored by Jinqn's avatar Jinqn

grunt合并压缩源代码

parent dc35c4bb
/*global module:false*/
module.exports = function (grunt) {
var banner = '/*!\n' +
' * ====================================================\n' +
' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * GitHub: <%= pkg.repository.url %> \n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
' * ====================================================\n' +
' */\n\n',
buildPath = 'dist/dev.php';
var getPath = function ( readFile) {
var sources = require("fs").readFileSync(readFile);
sources = /Array\(([^)]+)\)/.exec( sources );
sources = sources[1].replace( /\/\/.*\n/g, '\n' ).replace( /'|"|\n|\t|\s/g, '' );
sources = sources.split( "," );
sources.forEach( function ( filepath, index ) {
sources[ index ] = filepath;
});
return sources;
};
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
concat: {
js: {
options: {
banner: banner + '(function(kity, window) {\n\n',
footer: '\n\n})(kity, window)',
process: function(src, filepath) {
return src + "\n";
}
},
src: getPath( buildPath ),
dest: 'dist/kityminder.all.js'
}
},
uglify: {
options: {
},
minimize: {
files: {
'dist/kityminder.all.min.js': 'dist/kityminder.all.js'
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task.
grunt.registerTask( 'default', [ 'concat:js', 'uglify:minimize' ] );
};
{
"name": "kityminder",
"title": "kityminder",
"description": "Kity Minder",
"version": "1.1.0",
"homepage": "https://github.com/kitygraph/kityminder",
"author": {
"name": "Baidu UEditor Group",
"url": "http://ueditor.baidu.com"
},
"repository": {
"type": "git",
"url": "https://github.com/kitygraph/kityminder.git"
},
"keywords": [
"kityminder",
"kity",
"minder",
"svg",
"graphic",
"javascript"
],
"bugs": {
"url": "https://github.com/kitygraph/kityminder/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/kitygraph/kityminder/blob/dev/LICENSE"
}
],
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.6"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment