-
Notifications
You must be signed in to change notification settings - Fork 15
/
Gruntfile.js
123 lines (113 loc) · 3.08 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
/*global module:false*/
// Less - Custom
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\n'
},
// LESS
less: {
main: {
files: {
'<%= pkg.codename %>.css': 'src/<%= pkg.codename %>.less',
'<%= pkg.codename %>.ie.css': 'src/<%= pkg.codename %>.ie.less'
}
},
min: {
options: {
report: 'min',
cleancss: true
},
files: {
'<%= pkg.codename %>.min.css': 'src/<%= pkg.codename %>.less',
'<%= pkg.codename %>.ie.min.css': 'src/<%= pkg.codename %>.ie.less'
}
}
},
// Auto Prefixer
autoprefixer: {
options: {
browsers: [ '> 1%', 'last 5 versions', 'Firefox ESR', 'Opera 12.1', 'IE 8', 'IE 9' ]
},
no_dest: {
src: '*.css'
}
},
// Banner
usebanner: {
banner: {
options: {
position: 'top',
banner: '<%= meta.banner %>',
linebreak: false
},
files: {
src: [
'<%= pkg.codename %>.css',
'<%= pkg.codename %>.min.css',
'<%= pkg.codename %>.ie.css',
'<%= pkg.codename %>.ie.min.css'
]
}
}
},
// Bower sync
sync: {
all: {
options: {
sync: [ 'name', 'version', 'description', 'author', 'license', 'homepage' ],
overrides: {
main: [
'<%= pkg.codename %>.css'
],
ignore: [ "*.jquery.json" ]
}
}
}
},
// Watcher - For dev only!!
watch: {
styles: {
files: [
'src/**.less'
],
tasks: [
'less',
'autoprefixer'
]
}
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-watch');
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', [ 'less', 'autoprefixer', 'usebanner', 'sync', 'buildReadme' ]);
};