-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
125 lines (111 loc) · 3.1 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
module.exports = function(grunt) {
//Do grunt-related things in here
//grunt.loadNpmTasks('grunt-contrib');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-requirejs');
//Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Pull in the npm install package for possible variables
requirejs: {
compile : {
options : {
appDir: "app",
baseUrl: "js",
dir: "production/app",
name: 'main',
mainConfigFile: 'app/js/main.js',
optimizeCss: 'standard',
//How to optimize all the JS files in the build output directory.
optimize: "none",
removeCombined:true,
}
}
},
uglify: {
my_target: {
options: {
output: {
beautify: false
},
compress: {
sequences: false,
global_defs: {
DEBUG: false,
PRODUCTION: true
}
},
warnings: true,
mangle: false
},
files: {
'production/app/js/main.js': ['production/app/js/main.js']
}
}
},
clean: [
'production/app/tests',
'production/app/testRunner.html',
'production/app/css/sass',
'production/app/css/config.rb'
],
jshint: {
files: ['app/js/**/*.js']
},
shell: {
testemCI: {
options: {
stdout: true,
failOnError: true,
stderr: true
},
command: "testem ci | tee testem.tap"
},
postBuild:{
options: {
stdout: true
},
command: [
'cd production',
// save require.js but remove everything else in vendor dir
'mv vendor/requirejs/require.js require.js',
'rm -rf vendor',
'mkdir -p vendor/requirejs',
'mv require.js vendor/requirejs/require.js',
// save main.js but remove everything else in js dir
'mv js/main.js main.js',
'rm -rf js',
'mkdir js',
'mv main.js js/main.js'
].join('&&')
},
copyServer: {
command: [
'cp server.js production/server.js',
'cp package.json production/package.json',
'cp bower.json production/bower.json',
'cp -r config production/config',
'cp -r node_modules production/node_modules'
].join('&&')
}
},
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options: {
paths: 'app/js/.',
outdir: 'apidocs/'
}
}
}
});
grunt.registerTask('test', ['jshint', 'shell:testemCI']);
grunt.registerTask('default', ['requirejs', 'uglify', 'clean', 'shell:postBuild', 'shell:copyServer']);
};