-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathGruntfile.js
117 lines (115 loc) · 2.84 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
112
113
114
115
116
117
module.exports = function(grunt) {
var bannerContent = '/* \n' +
' * <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> \n' +
' * <%= pkg.description %> \n' +
' * <%= pkg.repository.url %> \n' +
' * \n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %> <[email protected]> \n' +
' * \n' +
' * Released under the <%= pkg.license %> license \n' +
'*/ \n',
name = '<%= pkg.name %>';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Copy
copy: {
src: {
nonull: true,
src: 'src/touchpoint.js',
dest: 'dist/touchpoint.js',
},
},
// Concat
concat: {
options: {
separator: ';',
banner: bannerContent
},
es5: {
src: ['dist/touchpoint.js'],
dest: 'dist/touchpoint-es5.js'
},
es6: {
src: ['src/touchpoint.js'],
dest: 'dist/touchpoint.js'
}
},
// Babel
babel: {
options: {
sourceMap: true,
presets: ['env']
},
convert: {
files: {
'dist/touchpoint-es5.js': 'dist/touchpoint.js'
}
}
},
// Uglify
uglify: {
options: {
banner: bannerContent
},
es5: {
files: {
'dist/touchpoint-es5.min.js': ['dist/touchpoint-es5.js']
}
}
},
// JS Hint
jshint: {
files: ['Gruntfile.js', 'touchpoint.js', 'test/touchpoint.js'],
options: {
// options here to override JSHint defaults
globals: {
console: true,
module: true,
document: true
}
}
},
// Watch
watch: {
options: {
livereload: true
},
js: {
files: [
'dist/*.js',
'*.html'
]
}
},
// Connect
connect: {
server: {
options: {
port: 9000,
base: '.',
hostname: '0.0.0.0',
protocol: 'http',
livereload: true,
open: true
}
}
}
});
// Load Tasks
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
// Register Tasks
grunt.registerTask('es6', ['babel']);
grunt.registerTask('jsErrors', ['jshint']);
grunt.registerTask('server', ['connect', 'watch']);
grunt.registerTask(
'build',
'Compiles all of the assets and copies the files to the build directory.',
['copy', 'concat', 'babel', 'uglify']
);
};