This repository was archived by the owner on Nov 29, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathGruntfile.js
183 lines (152 loc) · 5.83 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
module.exports = function(grunt) {
/**
* Load required Grunt tasks. These are installed based on the versions listed
* in `package.json` when you do `npm install` in this directory.
*/
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-urequire');
var buildDir = "/release";
var devDir = "/src";
/**
* This is the configuration object Grunt uses to give each plugin its
* instructions.
*/
var taskConfig = {
/**
* We read in our `package.json` file so we can access the package name and version. It's already there, so
* we don't repeat ourselves here.
*/
pkg: grunt.file.readJSON("package.json"),
/**
* The banner is the comment that is placed at the top of our compiled source files. It is first processed
* as a Grunt template, where the `<%=` pairs are evaluated based on this very configuration object.
*/
meta: {
banner: '/**\n' +
' * @appName <%= pkg.name %>\n' +
' * @version <%= pkg.version %>\n' +
' * @date <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * @homepage <%= pkg.homepage %>\n' +
' * @copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' +
' */\n'
},
/**
* The directories to delete when `grunt clean` is executed.
*/
clean: {
src: [
'<%= buildDir %>/*.js'
],
options: {
force: true
}
},
/**
* The `copy` task just copies files from A to B. We use it here to copy our project assets
* (images, fonts, etc.) and javascripts into `buildDir`, and then to copy the assets to `compileDir`.
*/
copy: {
release: {
files: [
{
src: './release/amd/angular-logX.js',
dest: './demos/webroot/assets/vendor/angular-logX/release/amd/angular-logX.js'
}
]
},
releaseMin: {
files: [
{
src: './release/amd/angular-logX.min.js',
dest: './demos/webroot/assets/vendor/angular-logX/release/amd/angular-logX.min.js'
}
]
}
},
/**
* Minifies RJS files and makes it production ready
* Build files are minified and encapsulated using RJS Optimizer plugin
*/
requirejs: {
compile: {
options: {
baseUrl: "./src",
paths :
{
// Configure alias to full paths; relative to `baseURL`
'logger': 'mindspace/logger',
'utils' : 'mindspace/utils'
},
out: './release/amd/angular-logX.js',
name: 'angular-logX',
preserveLicenseComments: true,
optimize: "none"
}
},
compileMin: {
options: {
baseUrl: "./src",
paths :
{
// Configure alias to full paths; relative to `baseURL`
'logger': 'mindspace/logger',
'utils' : 'mindspace/utils'
},
out: './release/amd/angular-logX.min.js',
name: 'angular-logX',
preserveLicenseComments: false,
optimize: "uglify"
}
}
},
bump: {
scripts: {
files: ["src/*.js"],
updateConfigs: ["pkg"],
commitFiles: ["-a"],
push: false
}
},
urequire:{
LibAsUMD: {
template: "UMD", // default, can be ommited
path: "./src",
dstPath: "./release/common/src"
},
LibCombinedToWorkEverywhere: {
template:'combined',
path: "./src",
main: 'angular-logX',
dstPath: "./release/common/angular-logX.all.js"
},
_defaults: {
verbose: false,
scanAllow: true,
allNodeRequires: true,
noRootExports: false
}
}
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize with configuration
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
grunt.initConfig( taskConfig );
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Register Tasks
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
grunt.registerTask( "release", [
'clean:src'
, "requirejs:compile" // concatenate and do NOT minify all the logDecorator source AMDs
, "copy:release"
]);
grunt.registerTask( "release.min", [
"requirejs:compileMin" // concatenate and minify all the logDecorator source AMDs
, "copy:releaseMin"
]);
grunt.registerTask('default', ['release','release.min']);
};