forked from a11y-tools/skipto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
175 lines (163 loc) · 4.45 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// jshint node: true, strict: false
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;' +
' Licensed <%= _.map(pkg.licenses, "type").join(", ") %> */\n' ,
bannerCond:
'/*@cc_on @*/\n' +
'/*@if (@_jscript_version >= 5.8) @*/\n',
footer: '/*@end @*/\n',
greaseBanner:
'// -----------------------------------------------------' + '\n' +
'// Title: Skip to Options User script' + '\n' +
'// version: <%= pkg.version %>' + '\n' +
'// Date: <%=grunt.template.today("yyyy-mm-dd")%>' + '\n' +
'// Author: <%= pkg.author %>' + '\n' +
'// Homepage: <%= pkg.homepage %>' + '\n' +
'// Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>' + '\n' +
'// -----------------------------------------------------' + '\n' +
'//' + '\n' +
'// ==UserScript==' + '\n' +
'// @name <%=pkg.name %>' + '\n' +
'// @namespace <%=pkg.name %>' + '\n' +
'// @description <%=pkg.description%>' + '\n' +
'// @include *' + '\n' +
'// ==/UserScript==' + '\n' + '\n',
jshint: {
files: [
'**/*.js',
'!**/*.min.js',
'!compiled/**',
'!node_modules/**'
],
options: {
jshintrc: "./src/js/.jshintrc"
}
},
concat: {
core: {
options: {
separator: ';',
banner: '<%= banner %> <%= bannerCond %>',
footer: '<%= footer %>'
},
src: ['src/js/<%= pkg.name %>.js'],
dest: './compiled/js/<%= pkg.name %>.js'
},
gm: {
options: {
banner: '<%= greaseBanner %>'
},
src: './compiled/js/<%= pkg.name %>.min.js',
dest: './compiled/js/<%= pkg.name %>.user.js'
}
},
uglify: {
options: {
sourceMap: './compiled/js/<%= pkg.name %>.min.map',
banner: '<%= banner %> <%= bannerCond %>',
footer: '<%= footer %>',
mangle: false,
sourceMappingURL: 'https://paypal.github.io/SkipTo/downloads/js/<%= pkg.name %>.min.map'
// , beautify: true
},
dist: {
files: {
'./compiled/js/<%= pkg.name %>.min.js': ['src/js/<%= pkg.name %>.js']
}
}
},
cssmin: {
target:{
files: {
'src/css/SkipTo.css': ['src/css/SkipTo.template.css']
}
}
},
replace: {
dist: {
options: {
variables: {
'cssContent': '<%= grunt.file.read("src/css/SkipTo.css") %>'
}
},
files: [{
expand: true,
flatten: true,
src: ['./compiled/js/<%= pkg.name %>.js', './compiled/js/<%= pkg.name %>.min.js'],
dest: './compiled/js/'
}
]
}
},
copy: {
main: {
files: [{
expand: true,
flatten: true,
src: ['./compiled/js/<%= pkg.name %>.min.js'],
dest: './src/WordPress/skipTo/js'
}, {
expand: true,
flatten: true,
src: ['./compiled/js/<%= pkg.name %>.min.js'],
dest: './src/Drupal/skipTo/js'
}
]
}
},
compress: {
WordPress: {
options: {
mode: 'zip',
archive: './compiled/WordPress/<%= pkg.name %>.zip'
},
files: [{
expand: true,
cwd: './src/WordPress/',
src: ['**'],
dest: '.',
filter: 'isFile'
}
]
},
Drupal: {
options: {
mode: 'tar',
archive: './compiled/Drupal/<%= pkg.name %>.tar'
},
files: [{
expand: true,
cwd: './src/Drupal/',
src: ['**'],
dest: '.',
filter: 'isFile'
}
]
}
},
clean: {
compiled: {
src: ["compiled/*", "./src/WordPress/skipTo/js/<%= pkg.name %>.min.js", "./src/Drupal/skipTo/js/<%= pkg.name %>.min.js"]
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('test', ['jshint']);
grunt.registerTask('wordpress', ['compress:WordPress']);
grunt.registerTask('drupal', ['compress:Drupal']);
grunt.registerTask('gm', 'concat:gm');
grunt.registerTask('default', ['jshint', 'concat:core', 'uglify', 'cssmin', 'replace', 'copy','concat:gm']);
grunt.registerTask('all', ['jshint', 'concat:core', 'uglify', 'replace', 'copy', 'compress', 'concat:gm']);
};