-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
137 lines (122 loc) · 2.95 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
module.exports = function(grunt) {
// Folder settings
var SOURCES = "source/";
var SOURCES_JS = SOURCES+"js/";
var SOURCES_SASS = SOURCES+"sass/";
var COMPILED = "public/";
var COMPILED_JS = COMPILED+"js/";
var COMPILED_SASS = COMPILED+"css/";
// JS Files
var JS_PREFIX = "App";
var JS_FILES = [
'global',
'view',
'api',
'tools'
];
// Fotmat JS Array
for(var i in JS_FILES){
JS_FILES[i] = SOURCES_JS+JS_PREFIX+"."+JS_FILES[i]+".js"
}
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
tag: {
banner: '/*!\n' +
' * DO NOT EDIT THIS FILE\n' +
' * File concatatenated by grunt @ <%= grunt.template.today("yyyy-mm-dd HH:MM") %>\n' +
' * <%= pkg.name %>\n' +
' * <%= pkg.title %>\n' +
' * <%= pkg.url %>\n' +
' * @author <%= pkg.author %>\n' +
' * @version <%= pkg.version %>\n' +
' * Copyright <%= pkg.copyright %>. <%= pkg.license %> licensed.\n' +
' */\n\n\n'
},
sass: {
dist: {
files: {
'public/css/main.css': 'source/sass/main.scss'
}
}
},
autoprefixer: {
options: {
browsers: ['last 8 versions']
},
dist: {
files: {
'public/css/main.css': 'public/css/main.css'
}
}
},
// JSHint
jshint: {
files: [SOURCES_JS+'/*.js'],
options: {
laxcomma: true,
boss: true,
curly: true,
eqeqeq: true,
eqnull: true,
es3: true,
browser: true,
smarttabs: true,
"-W099": true, // Relax rules on mixed tabs and spaces
globals: {
jQuery: true
}
}
},
// Concatatenated Javascript
concat: {
options: {
banner: '<%= tag.banner %>'
},
js: {
src: JS_FILES,
dest: COMPILED_JS+'app.js'
}
},
// Minified Javascript
uglify: {
options: {
banner: '/*! DO NOT EDIT THIS FILE */\n'+'/*! File Minified by grunt @ <%= grunt.template.today("yyyy-mm-dd HH:MM") %> */\n<%= tag.banner %>',
mangle: false
},
build: {
src: COMPILED_JS+'app.js',
dest: COMPILED_JS+'app.min.js'
}
},
// Watch files and build when they change
watch: {
css: {
files: [SOURCES_SASS+'*.scss'],
tasks: ['sass','autoprefixer']
},
js: {
files: [SOURCES_JS+'*.js'],
tasks: ['jshint','concat']
},
html: {
files: [COMPILED_SASS+'*', COMPILED+'*', COMPILED_JS+'*.js'],
options: {
// Start a live reload server on the default port 35729
livereload: true
}
}
},
notify_hooks: {
options: {
enabled: true,
max_jshint_notifications: 2, // maximum number of notifications from jshint output
title: "Oops!" // defaults to the name in package.json, or uses project's directory name, you can change to the name of your project
}
}
});
// Load grunt different tasks
require('load-grunt-tasks')(grunt);
grunt.task.run('notify_hooks');
// Register grunt tasks
grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'autoprefixer', 'watch', 'notify:watch']);
};