-
Notifications
You must be signed in to change notification settings - Fork 13
/
Gruntfile.js
108 lines (100 loc) · 2.7 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
// This builds the library itself
module.exports = function (grunt) {
// Configuration
grunt.initConfig({
concat: {
main: {
options: {
process: function (src, file) {
return /test\.js/.test(file) ? '' : src;
}
},
files: {
'superdom.js': ['src/superdom.js', 'src/plugins/*.js'],
// 'documentation.md': ['src/readme.md', 'src/plugins/**/readme.md']
}
}
},
usebanner: {
options: {
position: 'top',
banner: '/* Superdom.js v' + grunt.file.readJSON('package.json').version + ' by Francisco Presencia - MIT - https://github.com/franciscop/superdom.js */',
linebreak: true
},
files: {
src: [ './superdom.min.js' ]
}
},
// Super simple minifier that works with ES6
copy: {
main: {
src: 'superdom.js',
dest: 'superdom.min.js',
options: {
process: function (content, srcpath) {
return content
.replace(/\/\/[^\n]+/g, '')
.replace(/\/\*[^*]+\*\/\s+/, '')
.replace(/\n[^\S]*/g, ' ')
.replace(/\s?\=\>\s?/g, '=>')
.replace(/\s?\{\s?/g, '{')
.replace(/\s?\}\s?/g, '}')
.replace(/\s?\(\s?/g, '(')
.replace(/\s?\)\s?/g, ')')
.replace(/\s?\=\s?/g, '=')
.replace(/\s?\:\s?/g, ':')
.replace(/\s?\+\s?/g, '+')
.replace(/\s?\,\s?/g, ',')
.replace(/\s?\;\s?/g, ';')
.replace(/;}/g, '}')
;
}
}
}
},
semistandard: {
app: {
src: [
'src/**.js', '!src/**.test.js'
]
}
},
run: {
test: {
cmd: '/home/francisco/.nvm/versions/node/v7.2.1/bin/jest'
}
},
watch: {
scripts: {
files: [
'package.js', // To bump versions
'Gruntfile.js',
'src/**/*.js',
'__tests__/**/*'
],
tasks: ['default'],
options: {
spawn: false,
livereload: true
}
}
},
bytesize: {
all: {
src: [
'superdom.min.js'
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-semistandard');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-bytesize');
grunt.loadNpmTasks('grunt-run');
grunt.registerTask('build', ['concat', 'copy', 'usebanner', 'bytesize']);
grunt.registerTask('test', ['semistandard', 'run:test']);
grunt.registerTask('default', ['build', 'test']);
};