forked from robx/pzprjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
106 lines (98 loc) · 3.26 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
module.exports = function(grunt){
var pkg = grunt.file.readJSON('package.json'), deps = pkg.devDependencies;
for(var plugin in deps){ if(plugin.match(/^grunt\-/)){ grunt.loadNpmTasks(plugin);}}
var fs = require('fs');
var banner_min = fs.readFileSync('./src/common/banner_min.js', 'utf-8');
var banner_full = fs.readFileSync('./src/common/banner_full.js', 'utf-8');
var PRODUCTION = (grunt.cli.tasks.indexOf('release') >= 0);
grunt.initConfig({
pkg: pkg,
git: grunt.file.readJSON("git.json"),
copy: {
ui: {
options: {
process: function(content, srcpath){ return grunt.template.process(content);},
noProcess: ['**/*.{png,gif,ico}'],
mode: true
},
files : [
{ expand: true, cwd: 'src-ui/css', src: ['*.css'], dest: 'dist/css' },
{ expand: true, cwd: 'src-ui/img', src: ['*.png'], dest: 'dist/img' },
{ expand: true, cwd: 'src-ui', src: ['*'], dest: 'dist' }
]
}
},
concat: {
options: {
banner: banner_full,
process: true,
},
pzpr: {
options: {
sourceMap: !PRODUCTION
},
files: [
{ src: require('./src/pzpr.js').files, dest: 'dist/js/pzpr.concat.js' }
]
},
ui: {
options:{
sourceMap: !PRODUCTION
},
files: [
{ src: require('./src-ui/js/pzpr-ui.js').files, dest: 'dist/js/pzpr-ui.concat.js' }
]
}
},
uglify: {
options: {
banner: banner_min,
report: 'min'
},
pzpr:{
options: (PRODUCTION ? {} : {
sourceMap : 'dist/js/pzpr.js.map',
sourceMapIn : 'dist/js/pzpr.concat.js.map',
sourceMapIncludeSources : true
}),
files: [
{ src: 'dist/js/pzpr.concat.js', dest: 'dist/js/pzpr.js'}
]
},
variety:{
options: (PRODUCTION ? {} : {
sourceMap : function(filename){ return filename+'.map';}
}),
files: [
{ expand: true, cwd: 'src/variety', src: ['*.js'], dest: 'dist/js/pzpr-variety' }
]
},
samples:{
options: (PRODUCTION ? {} : {
sourceMap : function(filename){ return filename+'.map';}
}),
files: [
{ expand: true, cwd: 'test/script', src: ['*.js'], dest: 'dist/js/pzpr-samples' }
]
},
ui: {
options: (PRODUCTION ? {} : {
sourceMap : 'dist/js/pzpr-ui.js.map',
sourceMapIn : 'dist/js/pzpr-ui.concat.js.map',
sourceMapIncludeSources : true
}),
files: [
{ src: 'dist/js/pzpr-ui.concat.js', dest: 'dist/js/pzpr-ui.js' },
{ src: 'src-ui/js/list.js', dest: 'dist/js/list.js' }
]
}
}
});
grunt.registerTask('default', ['build']);
grunt.registerTask('release', ['build']);
grunt.registerTask('build', ['build:pzpr', 'build:variety', 'build:samples', 'build:ui']);
grunt.registerTask('build:pzpr', ['newer:concat:pzpr', 'newer:uglify:pzpr']);
grunt.registerTask('build:ui', ['newer:copy:ui', 'newer:concat:ui', 'newer:uglify:ui']);
grunt.registerTask('build:variety',['newer:uglify:variety']);
grunt.registerTask('build:samples',['newer:uglify:samples']);
};