-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathGruntfile.js
171 lines (168 loc) · 5.94 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dirs: {
src: './src',
doc: './doc',
bin: './build',
test: './test',
dest: './dist'
},
pluginName: '<%= pkg.name.replace("countdowntimer", "jQuery.countdownTimer") %>',
clean: {
build: ['<%= dirs.dest %>/*', '<%= dirs.doc %>/*', '<%= dirs.bin %>/*'],
tests: ['<%= dirs.test %>/*.min.tests.html']
},
copy: {
dist: {
files: [{
expand: true,
cwd: 'src',
src: ['*.html', 'css/*.*', 'js/**/*.*'],
dest: '<%= dirs.dest %>'
}]
}
},
uglify: {
dev: {
files: {
'<%= dirs.dest %>/js/<%= pluginName %>.js': ['<%= dirs.src %>/js/<%= pluginName %>.js']
},
options: {
beautify: true,
compress: false,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
expand: true,
output: {
comments: 'some'
}
}
},
min: {
files: {
'<%= dirs.dest %>/js/<%= pluginName %>.min.js': ['<%= dirs.dest %>/js/<%= pluginName %>.js']
},
options: {
report: 'min',
sourceMap: true,
expand: true,
output: {
comments: 'some'
}
}
}
},
qunit: {
all: ['<%= dirs.test %>/*.html']
},
jsdoc: {
options: {
destination: '<%= dirs.doc %>'
},
all: ['<%= dirs.src %>/js/*.js', 'README.md', '!<%= dirs.src %>/js/*-*.js']
},
jshint: {
files: ['Gruntfile.js', '<%= dirs.src %>/**/*.js', '<%= dirs.test %>/**/*.js', '!<%= dirs.src %>/bower_components/**/*.js'],
options: {
globals: {
jQuery: true,
console: true,
module: true
}
}
},
jsonlint: {
all: {
src: ['*.json']
}
},
eslint: {
target: ['Gruntfile.js', '<%= dirs.src %>/**/*.js', '<%= dirs.test %>/**/*.js', '!<%= dirs.src %>/bower_components/**/*.js']
},
compress: {
main: {
options: {
archive: '<%= dirs.bin %>/<%= pluginName %>-<%= pkg.version %>.zip'
},
expand: true,
cwd: '<%= dirs.dest %>',
src: ['**/*'],
dest: '<%= pluginName %>-<%= pkg.version %>'
}
},
version: {
dist: {
options: {
prefix: '@version\\s*',
replace: '[0-9a-zA-Z\\-_\\+\\.]+'
},
src: ['<%= dirs.dest %>/**/*.js', '<%= dirs.dest %>/**/*.css']
},
dev: {
options: {
prefix: '@version\\s*',
replace: '[0-9a-zA-Z\\-_\\+\\.]+'
},
src: ['<%= dirs.src %>/**/*.js', '<%= dirs.src %>/**/*.css', '!<%= dirs.src %>/bower_components/**/*.*']
},
project: {
src: ['*.json']
}
},
replace: {
dist: {
src: ['<%= dirs.dest %>/index.html'],
dest: '<%= dirs.dest %>/index.html',
replacements: [{
from: /bower_components\/jquery\/dist\/jquery.min.js/,
to: 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'
}]
},
datejs: {
src: ['<%= dirs.dest %>/js/<%= pluginName %>.js'],
dest: ['<%= dirs.dest %>/js/<%= pluginName %>.js'],
replacements: [{
from: /@date/,
to: "<%= grunt.template.today('dd/mm/yyyy') %>"
}]
},
datecss: {
src: ['<%= dirs.dest %>/css/<%= pluginName %>.css'],
dest: ['<%= dirs.dest %>/css/<%= pluginName %>.css'],
replacements: [{
from: /@date/,
to: "<%= grunt.template.today('dd/mm/yyyy') %>"
}]
},
testmin: {
src: ['<%= dirs.test %>/countdownTimer.tests.html'],
dest: '<%= dirs.test %>/countdownTimer.min.tests.html',
replacements: [{
from: /src\/js\/jQuery\.(.*)\.js/g,
to: '<%= dirs.dest %>/js/jQuery.$1.min.js'
}]
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint', 'qunit', 'eslint']
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-jsonlint');
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['clean:build', 'clean:tests', 'eslint', 'jshint', 'jsonlint']);
grunt.registerTask('dist', ['copy:dist', 'replace:dist', 'replace:datejs', 'replace:datecss']);
grunt.registerTask('test:unit', ['jshint', 'jsonlint', 'eslint']);
grunt.registerTask('build', ['uglify:min', 'version:dist', 'version:project', 'jsdoc', 'compress']);
grunt.registerTask('test', ['eslint', 'jshint', 'jsonlint', 'replace:testmin', 'qunit']);
};