This repository has been archived by the owner on Feb 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
127 lines (117 loc) · 3.64 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
var _ = require('underscore');
module.exports = function(grunt) {
var appScripts = [
'app.js',
'controller.js',
'directives.js',
'services.js'
];
var libScripts = [
'angular/angular.js',
'angular-resource/angular-resource.js',
'angular/angular-mobile.js',
'angular-mobile-nav/mobile-nav.js',
'underscore/underscore-min.js',
'moment/moment.min.js'
];
appScripts = _.map(appScripts, function(file){
return 'public/src/' + file;
});
libScripts = _.map(libScripts, function(file){
return 'public/src/lib/' + file;
});
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
env: {
dev: {
NODE_ENV : 'DEVELOPMENT',
publicDir: 'public'
},
prod : {
NODE_ENV : 'PRODUCTION',
publicDir: 'build'
}
},
preprocess: {
dev: {
src: 'public/index.html',
dest: 'build/index.html'
},
prod: {
src: 'public/index.html',
dest: 'build/index.html',
options: {
context: {
name: '<%= pkg.name %>',
version: '<%= pkg.version %>',
now: '<%= now %>',
ver: '<%= ver %>'
}
}
}
},
clean: {
dev: ['build/'],
prod: ['build/']
},
uglify: {
prod: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
compress: true
},
files: {
'build/app.min.js': appScripts,
'build/libs.min.js': libScripts
}
}
},
cssmin: {
minify:{
expand: true,
cwd: 'public/assets/css/',
src: ['mobile-nav.css', 'style.css'],
dest: 'build/assets/css/'
}
},
copy: {
prod: {
files: [
{expand: true, cwd: 'public', src: ['assets/**', 'templates/**'], dest: 'build/'}
]
}
},
express: {
options: {
background: false,
script: 'server.js'
},
dev: {
},
prod: {
}
},
forever: {
options:{
index: 'server.js'
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-preprocess');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-forever');
// Default task(s).
//grunt.registerTask('prod', ['env:prod', 'clean:prod', 'uglify:prod', 'cssmin:prod', 'copy:prod', 'preprocess:prod']);
grunt.registerTask('buildprod', ['env:prod', 'clean:prod', 'uglify:prod', 'cssmin', 'copy:prod', 'preprocess:prod']);
grunt.registerTask('startdev', ['express']);
grunt.registerTask('start', ['startdev']);
grunt.registerTask('startprod', ['buildprod', 'forever:start']);
grunt.registerTask('stopprod', ['forever:stop']);
};