forked from hockic/bootstrap-wysihtml5
-
Notifications
You must be signed in to change notification settings - Fork 111
/
Gruntfile.js
111 lines (105 loc) · 3.28 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
107
108
109
110
111
module.exports = function(grunt) {
grunt.registerTask('bowerupdate', 'update the frontend dependencies', function() {
var exec = require('child_process').exec;
var cb = this.async();
exec('bower update', {cwd: '.'}, function(err, stdout, stderr) {
console.log(stdout);
cb();
});
});
grunt.registerTask('npmupdate', 'update the development dependencies', function() {
var exec = require('child_process').exec;
var cb = this.async();
exec('npm update', {cwd: '.'}, function(err, stdout, stderr) {
console.log(stdout);
cb();
});
});
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
handlebars: {
compile: {
options: {
namespace: 'wysihtml5.tpl',
processName: function(filePath) {
return filePath.split('/')[2].split('.')[0];
},
node: true
},
files: {
'src/generated/templates.js': ['src/templates/*.hbs']
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
compress: {
drop_console: true
}
},
build: {
files: {
'dist/bootstrap3-wysihtml5.min.js': [
'src/generated/templates.js',
'src/bootstrap3-wysihtml5.js',
'src/generated/commands.js',
'src/locales/bootstrap-wysihtml5.en-US.js'
],
'dist/bootstrap3-wysihtml5.all.min.js': [
'components/wysihtml5/dist/wysihtml5-0.3.0.min.js',
'components/handlebars/handlebars.runtime.min.js',
'src/generated/templates.js',
'src/bootstrap3-wysihtml5.js',
'src/generated/commands.js',
'src/locales/bootstrap-wysihtml5.en-US.js'
]
}
}
},
cssmin: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
minify: {
files: {
'dist/bootstrap3-wysihtml5.min.css': ['src/bootstrap3-wysihtml5.css']
}
}
},
clean: {
build: ["dist"]
},
copy: {
main: {
files: [
{expand: true, cwd: 'src/', src: ['*.js'], dest: 'dist/'},
{expand: true, cwd: 'src/', src: ['*.css'], dest: 'dist/'},
{expand: true, cwd: 'src/generated', src: ['*.js'], dest: 'dist/'},
{expand: true, cwd: 'src/', src: ['locales/*.js'], dest: 'dist/'},
]
}
},
concat: {
options: {
separator: '',
},
commands: {
src: ['src/commands/small.js'],
dest: 'src/generated/commands.js',
},
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-handlebars');
// Default task(s).
grunt.registerTask('dev', ['handlebars', 'concat:commands']);
grunt.registerTask('build', ['clean:build', 'handlebars', 'concat:commands', 'uglify', 'cssmin', 'copy']);
grunt.registerTask('with-update', ['bowerupdate', 'npmupdate', 'build']);
grunt.registerTask('default', ['build']);
};