forked from MinnPost/jquery-vertical-timeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
180 lines (164 loc) · 4.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
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
176
177
178
179
180
/* global module:false */
/**
* Grunt file that handles managing tasks such as rendering
* SASS, providing a basic HTTP server, building a
* distribution, and deploying.
*/
module.exports = function(grunt) {
var _ = grunt.util._;
// Project configuration. Many values are directly read from
// package.json.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
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.name %>;' +
' Licensed <%= pkg.license || _.pluck(pkg.licenses, "type").join(", ") %> */' +
'<%= "\\n\\n" %>'
},
// Clean up the distribution fold
clean: {
folder: 'dist/'
},
// JS Hint checks code for coding styles and possible errors
jshint: {
options: {
curly: true,
es3: true,
forin: true,
latedef: true,
//maxlen: 80,
indent: 2,
multistr: true
},
files: ['Gruntfile.js', 'js/*.js']
},
// Compass is an extended SASS. Set it up so that it generates to .tmp/
compass: {
options: {
sassDir: 'styles',
cssDir: '.tmp/css',
generatedImagesDir: '.tmp/images',
fontsDir: 'styles/fonts',
imagesDir: 'images',
javascriptsDir: 'js',
importPath: 'bower_components',
httpPath: './',
relativeAssets: true
},
dist: {
options: {
environment: 'production',
outputStyle: 'expanded',
cssDir: '.tmp/css'
}
}
},
// Copy relevant files over to distribution
copy: {
images: {
files: [
{
cwd: './images/',
expand: true,
src: ['**'],
dest: 'dist/images/'
}
]
}
},
// Brings files toggether
concat: {
options: {
separator: '\r\n\r\n'
},
// JS version
js: {
src: ['js/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
},
// CSS
css: {
src: ['.tmp/css/styles.css'],
dest: 'dist/<%= pkg.name %>.css'
},
// Libs
libs: {
src: [
'bower_components/jquery/jquery.min.js',
'bower_components/underscore/underscore-min.js',
'bower_components/tabletop/src/tabletop.js',
'bower_components/momentjs/min/moment.min.js',
'bower_components/isotope/jquery.isotope.min.js',
'bower_components/eventEmitter/eventEmitter.min.js',
'bower_components/eventie/eventie.js',
'bower_components/imagesloaded/imagesloaded.js'
],
dest: 'dist/<%= pkg.name %>.libs.js'
}
},
// Replace some stuff
replace: {
imagePath: {
src: ['dist/<%= pkg.name %>.css'],
dest: 'dist/<%= pkg.name %>.css',
replacements: [{
from: "url('../../images",
to: "url('./images"
}]
}
},
// Minify JS for network efficiency
uglify: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
src: ['dist/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.min.js'
}
},
// Minify CSS for network efficiency
cssmin: {
options: {
banner: '<%= meta.banner %>',
report: true
},
css: {
src: ['dist/<%= pkg.name %>.css'],
dest: 'dist/<%= pkg.name %>.min.css'
}
},
// HTTP Server
connect: {
server: {
options: {
port: 8888
}
}
},
// Watches files for changes and performs task
watch: {
files: ['<%= jshint.files %>', 'styles/*.scss'],
tasks: 'watcher'
}
});
// Load plugin tasks
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-text-replace');
// Default build task
grunt.registerTask('default', ['jshint', 'compass:dist', 'clean', 'copy', 'concat', 'replace', 'cssmin', 'uglify']);
// Server and watch
grunt.registerTask('watcher', ['default']);
grunt.registerTask('server', ['connect', 'watch']);
};