-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
174 lines (166 loc) · 4.15 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
/*global module:false*/
// Less
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/* \n' +
' * <%= pkg.name %> v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> \n' +
' * <%= pkg.description %> \n' +
' * <%= pkg.homepage %> \n' +
' * \n' +
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>; <%= pkg.license %> Licensed \n' +
' */\n'
},
// JS Hint
jshint: {
options: {
globals: {
'jQuery': true,
'$' : true
},
browser: true,
curly: true,
eqeqeq: true,
forin: true,
freeze: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
nonew: true,
smarttabs: true,
sub: true,
undef: true,
validthis: true
},
files: [
'src/<%= pkg.codename %>.js'
]
},
// Copy
copy: {
main: {
files: [
{
src: 'src/<%= pkg.codename %>.js',
dest: '<%= pkg.codename %>.js'
}
]
}
},
// Uglify
uglify: {
options: {
report: 'min'
},
target: {
files: {
'<%= pkg.codename %>.min.js': [ '<%= pkg.codename %>.js' ]
}
}
},
// jQuery Manifest
jquerymanifest: {
options: {
source: grunt.file.readJSON('package.json'),
overrides: {
name: '<%= pkg.id %>',
keywords: '<%= pkg.keywords %>',
homepage: '<%= pkg.homepage %>',
docs: '<%= pkg.homepage %>',
demo: '<%= pkg.homepage %>',
download: '<%= pkg.repository.url %>',
bugs: '<%= pkg.repository.url %>/issues',
dependencies: {
jquery: '>=1.7'
}
}
}
},
// LESS
less: {
main: {
files: {
'<%= pkg.codename %>.css': 'src/<%= pkg.codename %>.less'
}
},
min: {
options: {
report: 'min',
cleancss: true
},
files: {
'<%= pkg.codename %>.min.css': 'src/<%= pkg.codename %>.less'
}
}
},
// Auto Prefixer
autoprefixer: {
options: {
borwsers: [ '> 1%', 'last 5 versions', 'Firefox ESR', 'Opera 12.1', '>= ie 8' ]
},
no_dest: {
src: '*.css'
}
},
// Banner
usebanner: {
options: {
position: 'top',
banner: '<%= meta.banner %>'
},
files: {
src: [
'<%= pkg.codename %>.css',
'<%= pkg.codename %>.js',
'<%= pkg.codename %>.min.css',
'<%= pkg.codename %>.min.js'
]
}
},
//Bower sync
sync: {
all: {
options: {
sync: [ 'name', 'version', 'description', 'author', 'license', 'homepage' ],
overrides: {
main: [
'<%= pkg.codename %>.js',
'<%= pkg.codename %>.css'
],
ignore: [ "*.jquery.json", "Gruntfile.js", "src/" ]
}
}
}
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jquerymanifest');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-npm2bower-sync');
// Readme
grunt.registerTask('buildReadme', 'Build Formstone README.md file.', function () {
var pkg = grunt.file.readJSON('package.json'),
extra = grunt.file.exists('src/README.md') ? '\n\n---\n\n' + grunt.file.read('src/README.md') : '';
destination = "README.md",
markdown = '<h2>Development of this plugin has ended. Please upgrade to the new <a href="http://formstone.it">Formstone</a>.</h2><br> \n\n' +
'<a href="http://gruntjs.com" target="_blank"><img src="https://cdn.gruntjs.com/builtwith.png" alt="Built with Grunt"></a> \n' +
'# ' + pkg.name + ' \n\n' +
pkg.description + ' \n\n' +
'- [Demo](' + pkg.demo + ') \n' +
'- [Documentation](' + pkg.homepage + ') \n\n' +
'#### Bower Support \n' +
'`bower install ' + pkg.name + '` ' +
extra;
grunt.file.write(destination, markdown);
grunt.log.writeln('File "' + destination + '" created.');
});
// Default task.
grunt.registerTask('default', [ 'jshint', 'copy', 'uglify', 'jquerymanifest', 'less', 'autoprefixer', 'usebanner', 'sync', 'buildReadme' ]);
};