-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntFile.js
More file actions
117 lines (108 loc) · 4.4 KB
/
GruntFile.js
File metadata and controls
117 lines (108 loc) · 4.4 KB
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
/*
* grunt
* http://gruntjs.com/
*
* Copyright (c) 2013 "Cowboy" Ben Alman
* Licensed under the MIT license.
* https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
*/
// The first part is the "wrapper" function, which encapsulates your Grunt configuration
module.exports = function(grunt) {
'use strict';
// Project configuration
grunt.initConfig({
// Next we can read in the project settings from the package.json file into the pkg property. This allows us to refer to the values of properties within our package.json file.
pkg: grunt.file.readJSON('package.json'),
// Configure the copy task to move files from the development to production folders
// copy: { // Task
// target: {
// files: {
// 'dist/': ['index.html', 'demo/**'] // 'destination': 'source'
// }
// }
// },
clean: {
folder: "dist"
},
uglify: { // Task
options: {
// The banner is inserted at the top of the output
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: { // Target
files: { // Dictionary of files
'dist/js/<%= pkg.name %>.min.js': ['src/js/_.config.js', 'src/js/_.main.js', 'src/js/_.helper.js'],
'dist/demo/js/fb.friends.min.js': ['src/demo/js/fb.config.js', 'src/demo/js/fb.friends.list.js'],
'dist/js/libs/jquery.min.js': ['src/js/libs/jquery.js'],
'dist/js/libs/require.min.js': ['src/js/libs/require.js']
}
}
},
htmlmin: { // Task
dist: { // Target
options: { // Target options
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
removeComments: false,
collapseWhitespace: false
},
files: { // Dictionary of files
'dist/index.html': 'src/index.html', // 'destination': 'source'
'dist/demo/facebook_friends_list.html': 'src/demo/facebook_friends_list.html'
}
}
},
cssmin: { // Task
combine: {
files: { // Dictionary of files
'dist/css/style.min.css': ['src/css/style.css'],
'dist/demo/css/style.min.css': ['src/demo/css/style.css']
}
}
},
jshint: { // Task
// Define the files to lint
files: ['Gruntfile.js', 'src/js/*.js', 'src/demo/js/*.js'],
// Configure JSHint (documented at http://www.jshint.com/docs/)
options: {
// More options here if you want to override JSHint defaults
jshintrc: '.jshintrc'
}
},
// watch: { // Task
// files: ['<%= jshint.files %>'],
// tasks: ['jshint']
// },
useminPrepare: {
html: 'dist/index.html'
},
usemin: {
//html: 'dist/index.html'
html: ['dist/{,*/}*.html'],
css: ['dist/css/{,*/}*.css'],
options: {
dirs: ['dist']
}
}
});
// Finally, we have to load in the Grunt plugins we need. These should have all been installed through npm
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-usemin');
//grunt.loadNpmTasks('grunt-contrib-watch');
//grunt.loadNpmTasks('grunt-contrib-copy');
// Let's set up some tasks
grunt.registerTask('test', ['jshint']);
// The default task can be run just by typing "grunt" on the command line
grunt.registerTask('default', ['clean', 'useminPrepare', 'jshint', 'uglify', 'cssmin', 'htmlmin', 'usemin']);
};