forked from noelboss/featherlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
119 lines (110 loc) · 2.58 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
module.exports = function(grunt) {
var banner = '/**\n'
+ ' * <%= pkg.title %>\n'
+ ' * Version <%= pkg.version %> - <%= pkg.homepage %>\n'
+ ' *\n'
+ ' * Copyright <%= grunt.template.today("yyyy") %>, <%= pkg.author.name %> (<%= pkg.author.url %>)\n'
+ ' * MIT Licensed.\n'
+ '**/';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
replace: {
src: {
src: ['./README.md','./src/*.*'],
overwrite: true,
replacements: [
{
from: /Copyright\s[0-9]{4}/g,
to: 'Copyright <%= grunt.template.today("yyyy") %>'
},
{
from: /\*\sVersion\s[0-9]+[.]{1}[0-9]+[.]{1}[0-9]+/g,
to: '* Version <%= pkg.version %>'
},
{
from: /Current\sRelease\s[0-9]+[.]{1}[0-9]+[.]{1}[0-9]+/g,
to: 'Current Release <%= pkg.version %>'
},
{
from: /archive\/[0-9]+[.]{1}[0-9]+[.]{1}[0-9]+/g,
to: 'archive/<%= pkg.version %>'
},
{
from: /noelboss\/featherlight\/[0-9]+[.]{1}[0-9]+[.]{1}[0-9]+/g,
to: 'noelboss/featherlight/<%= pkg.version %>'
},
{
from: /"version": "[0-9]+[.]{1}[0-9]+[.]{1}[0-9]+"/g,
to: '"version": "<%= pkg.version %>"'
},
{
from: /\([0-9]+[.]{1}[0-9]+[.]{1}[0-9]+\)/g,
to: '(<%= pkg.version %>)'
}
]
},
},
less: {
featherlight: {
options: {
compress: true,
sourceMap: true,
sourceMapBasepath: 'src/',
sourceMapRootpath: './',
sourceMapURL: function(path) { return path.replace(/.*\//, '') + '.map'; },
relativeUrls: true
},
files: {
'dist/featherlight.min.css' : 'src/featherlight.less'
}
},
},
uglify: {
featherlight: {
options: {
banner: banner+'\n',
sourceMap: true,
},
files: {
'dist/featherlight.min.js' : ['src/featherlight.js']
}
}
},
watch: {
replace: {
files: [
'package.json',
],
tasks: ['replace']
},
less: {
files: [
'src/featherlight.less',
],
tasks: ['less']
}
},
jshint: {
options: {
laxbreak: true,
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
reporterOutput: "",
globals: {
jQuery: true,
Hammer: true,
el: true
},
},
uses_defaults: ['src/**/*.js']
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['replace', 'less', 'uglify']);
grunt.registerTask('test', ['jshint']);
};