forked from bfricka/less-preview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
113 lines (103 loc) · 2.72 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
var scripts = require('./express/app-scripts')(process.cwd());
var src = scripts.development();
module.exports = function(grunt) {
var js_globals = Object.keys(grunt.file.readJSON('./.jshintrc').globals);
var uglify_options = {
compress: {
loops : true,
unused : true,
unsafe : true,
cascade : true,
warnings : true,
booleans : true,
evaluate : true,
dead_code : true,
join_vars : true,
if_return : true,
sequences : true,
hoist_vars : false,
hoist_funs : true,
properties : true,
comparisons : true,
conditionals : true
},
mangle: { except: js_globals }
};
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: [
'/* <%= pkg.name %> - v<%= pkg.version %> - <%= pkg.homepage %>',
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>. All rights reserved.',
' * Licensed <%= _.pluck(pkg.licenses, "type")[0] %> - <%= _.pluck(pkg.licenses, "url")[0] %>',
' */',
''
].join('\n')
},
paths: {
js : './public/javascripts',
tmp : './tmp',
test : './test',
routes : './routes',
express : './express'
},
concat: {
app: {
src: src.app,
dest: '<%= paths.tmp %>/less2css.js'
},
vendor: {
src: src.vendor,
dest: '<%= paths.tmp %>/vendor.js'
},
build: {
options: { banner: '<%= meta.banner %>'},
files: {
'<%= paths.js %>/less2css.min.js': ['<%= paths.js %>/less2css.min.js']
}
}
},
watch: {
js: {
files: [
'<%= paths.js %>/options-drawer.js',
'<%= paths.js %>/src/**/*.js'
],
tasks: ['concat:app', 'jshint']
},
tests: {
files: ['<%= paths.test %>/**/*.spec.js'],
tasks: ['karma:unit:run']
}
},
uglify: {
app: {
options: uglify_options,
files: {
'<%= paths.js %>/less2css.min.js': ['<%= paths.tmp %>/less2css.js']
}
},
vendor: {
options: uglify_options,
files: {
'<%= paths.js %>/vendor.min.js': ['<%= paths.tmp %>/vendor.js']
}
}
},
jshint: {
options: { jshintrc: './.jshintrc' },
all: ['<%= paths.tmp %>/less2css.js']
}
});
grunt.registerTask('default', [
'concat:app',
'concat:vendor',
'jshint',
'uglify',
'concat:build'
]);
};