forked from 720kb/angular-socialshare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
125 lines (114 loc) · 3.28 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
/*global module, require*/
(function setUp(module, require) {
'use strict';
var banner = ['/*!',
' * Angular Socialshare v<%= pkg.version %>',
' *',
' * Released by 720kb.net under the MIT license',
' * www.opensource.org/licenses/MIT',
' *',
' * <%= grunt.template.today("yyyy-mm-dd") %>',
' * source link: //github.com/720kb/angular-socialshare',
' */\n\n'].join('\n')
, modRewrite = require('connect-modrewrite');
module.exports = function doGrunt(grunt) {
grunt.initConfig({
'pkg': grunt.file.readJSON('package.json'),
'confs': {
'dist': 'dist',
'config': 'config',
'js': 'src/js',
'serverPort': 8000
},
'eslint': {
'options': {
'config': '<%= confs.config %>/eslint.json'
},
'target': [
'Gruntfile.js',
'<%= confs.js %>/**/*.js'
]
},
'uglify': {
'options': {
'sourceMap': true,
'sourceMapName': '<%= confs.dist %>/angular-socialshare.sourcemap.map',
'preserveComments': false,
'report': 'gzip',
'banner': banner
},
'minifyTarget': {
'files': {
'<%= confs.dist %>/angular-socialshare.min.js': [
'<%= confs.js %>/angular-socialshare.js'
]
}
}
},
'connect': {
'server': {
'options': {
'port': '<%= confs.serverPort %>',
'base': '.',
'keepalive': true,
'middleware': function manageMiddlewares(connect, options) {
var middlewares = []
, directory = options.directory || options.base[options.base.length - 1];
// enable Angular's HTML5 mode
middlewares.push(modRewrite(['!\\.html|\\.js|\\.svg|\\.css|\\.png|\\.gif$ /index.html [L]']));
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
options.base.forEach(function forEachOption(base) {
// Serve static files.
middlewares.push(connect.static(base));
});
// Make directory browse-able.
middlewares.push(connect.directory(directory));
return middlewares;
}
}
}
},
'watch': {
'dev': {
'files': [
'Gruntfile.js',
'<%= confs.js %>/**/*.js'
],
'tasks': [
'eslint'
],
'options': {
'spawn': false
}
}
},
'concurrent': {
'dev': {
'tasks': [
'connect:server',
'watch:dev'
],
'options': {
'limit': '<%= concurrent.dev.tasks.length %>',
'logConcurrentOutput': true
}
}
}
});
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'eslint',
'concurrent:dev'
]);
grunt.registerTask('prod', [
'eslint',
'uglify'
]);
};
}(module, require));