-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
139 lines (128 loc) · 2.76 KB
/
Gruntfile.coffee
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
138
139
module.exports = (grunt) ->
require("matchdep").filterDev("grunt-*").forEach grunt.loadNpmTasks
tasks = {
dev: [
"clean:all"
"version"
"svgsjson"
"sprites"
"sass"
"copy:img"
"copy:models"
"pack"
"coffee:dev"
"writeEnvFile:dev"
"concat-json"
"copy:dev"
"copy:fonts"
"copy:vendors"
"copy:medias"
"copy:pdf"
"copy:workers"
"browserSync"
"watch"
]
preprod: [
"clean:all"
"version"
"svgsjson"
"sprites"
"sass"
"copy:img"
"copy:models"
"pack"
"coffee:preprod"
"concat:vendors_preprod"
"writeEnvFile:preprod"
"concat-json"
"copy:preprod"
"copy:fonts"
"copy:medias"
"copy:pdf"
"copy:js"
"copy:workers"
# "uglify"
"clean:js"
]
staging: [
"clean:all"
"version"
"svgsjson"
"sprites"
"sass"
"copy:img"
"copy:models"
"pack"
"coffee:staging"
"concat:vendors_staging"
"writeEnvFile:staging"
"concat-json"
"gaeConf:staging"
"copy:staging"
"copy:fonts"
"copy:medias"
"copy:pdf"
"copy:js"
"copy:workers"
"uglify"
"clean:js"
]
prod: [
"clean:all"
"version"
"svgsjson"
"sprites"
"sass"
"copy:img"
"copy:models"
"pack"
"coffee:prod"
"concat:vendors_prod"
"writeEnvFile:prod"
"concat-json"
"gaeConf:prod"
"copy:prod"
"copy:fonts"
"copy:medias"
"copy:pdf"
"copy:js"
"copy:workers"
"uglify"
"clean:js"
]
}
srcPath = "src"
buildPath = "dist"
assetsPath = "static"
javascriptsFiles = grunt.file.readJSON("dist/shared/datas/javascripts.json")
gruntFolder = "./grunt"
assetsFolder = buildPath + "/" + assetsPath
config =
globalConfig:
gruntTasksFolder: gruntFolder
srcPath: srcPath
buildPath: buildPath
builds: javascriptsFiles.builds
srcs: javascriptsFiles.files.src
vendors: javascriptsFiles.files.vendors
assetsFolder: assetsFolder
assetsPath: assetsPath
localConfFile = gruntFolder + "/config/local.json"
if grunt.file.exists localConfFile
localConf = grunt.file.readJSON localConfFile
config.globalConfig.serverHost = localConf.host
if localConf.sourceMap?
config.globalConfig.sourceMap = localConf.sourceMap
else
config.globalConfig.sourceMap = true
else
config.globalConfig.sourceMap = false
grunt.option "globalConfig", config.globalConfig
grunt.option "tasksList", tasks
grunt.file.expand({cwd: config.globalConfig.gruntTasksFolder}, ["*.coffee", "*.js"]).forEach (path) ->
taskConfig = require(config.globalConfig.gruntTasksFolder + "/" + path.replace("/\.(js|coffee)$/", ""))
taskConfig = taskConfig(grunt) if typeof taskConfig is "function"
grunt.util._.extend config, taskConfig
grunt.initConfig config
grunt.registerTask "default", tasks.dev
grunt.registerTask "build", ["prompt:build", "buildDist"]