-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
165 lines (142 loc) · 5.08 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
/*
* Copyright (c) 2016 pro!vision GmbH and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
"use strict";
var path = require("path");
module.exports = function(grunt) {
// load local tasks
grunt.loadTasks('tasks');
// Project configuration.
grunt.initConfig({
clean: {
"result": ["test/result/**"]
},
nodeunit: {
tests: ["test/*.test.js"]
},
clientlib: {
// define options globally (used for all targets)
options: {
clientLibRoot: "./test/result/clientlibs-root", // clientlib root path
cwd: "./test/src/frontend"
},
// target key will be used as clientlib name
"test.base.apps.mainapp": {
// collect all JS files within js directory
"js": {
flatten: false, // keep source directory structure
cwd: "./test/src/frontend/js",
// Important: the order defines how AEM merges/bundles the JavaScript files.
// This is important for dependencies within JavaScript files
src: [
"**/*.js", // find all JavaScript files
"!app.js", // exclude app.js because
"app.js" // it should be at the end (in the clientlib)
]
},
// create clientLibs in /apps/myapp/clientlibs and allow proxy to /etc.clientlibs/myapp
"allowProxy": true,
// allow URL Fingerprinting via placeholder
"longCacheKey": "${project.version}-${buildNumber}",
// collect all CSS files within css directory
// Important: use globbing only if the files haven't any dependencies to
// each other. The order can be different between Unix and Windows systems.
"css": "css/**/*.css"
},
"test.base.apps.secondapp": {
options: {
cwd: "./test/src/frontend/secondapp" // will override the global `cwd`
},
"embed": [
"test.base.apps.thirdapp" // this clientlib will be auto embedded in AEM (kind of `merging`)
],
"dependencies": [
"test.base.apps.mainapp" // define clientlib dependency
],
"categories": [
"test.categorie.in.config"
],
"cssProcessor": ["default:none", "min:none"], // disable minification
"jsProcessor": ["default:none", "min:gcc"], // using google closure compiler instead of YUI for minification
// example for copy & rename (for a single file)
"js": {
// source to be copied
src: "js/lib.js",
// renames lib.js to secondapp-lib.js
rename: "secondapp-lib.js"
},
"css": {
base: "style", // change base dir from `css` (default) to `style` within the client lib folder
src: "main.css"
},
"resources": {
cwd: "./test/src/frontend/",
base: ".", // using root from this clientlib
flatten: false, // and keep directory structure from src
src: [
"resources/**",
"!resources/**/*.txt"
]
}
},
"test.base.apps.thirdapp": {
// keep in mind we are using `cwd` from options
resources: {
base: ".", // use the clientlib subfolder instead of the default `resources` directory
flatten: false, // keep the original folder structure from src
src: [
"resources/**/*.txt"
]
}
},
"test.base.apps.serializationFormatXML": {
options: {
cwd: "./test/src/frontend/secondapp"
},
"serializationFormat": "xml",
"categories": [
"test.base.apps.six",
"test.categorie.in.config"
],
"embed": [
"test.base.apps.thirdapp" // this clientlib will be auto embedded in AEM (kind of `merging`)
],
"dependencies": "test.base.apps.mainapp",
"js": {
"src": "js/lib.js",
"rename": "secondapp-lib.js"
},
"css": {
base: "style", // changes the `base` from `css` (default) to `style`
src: "main.css"
},
"resources": {
cwd: "./test/src/frontend/",
base: ".", // using root from this clientlib
flatten: false, // and keep directory structure from src
src: [
"resources/**",
"!resources/**/*.txt"
]
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-nodeunit");
// default task will be used for 'frontend sync'
grunt.registerTask("default", ["clean", "clientlib", "nodeunit"]);
};