-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
169 lines (164 loc) · 4.52 KB
/
Gruntfile.js
File metadata and controls
169 lines (164 loc) · 4.52 KB
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
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json'),
// Browsers you care about for autoprefixing. Browserlist https://github.com/ai/browserslist
// The following list is set as per WordPress requirements. Though, Feel free to change.
BROWSERS_LIST = [
'last 2 version',
'> 1%',
'ie >= 11',
'last 1 Android versions',
'last 1 ChromeAndroid versions',
'last 2 Chrome versions',
'last 2 Firefox versions',
'last 2 Safari versions',
'last 2 iOS versions',
'last 2 Edge versions',
'last 2 Opera versions'
];
grunt.initConfig({
pkg: pkg,
foo: {
banner: '/*!\n' +
'* <%= pkg.title %> - <%= pkg.description %>\n' +
'* @version <%= pkg.version %>\n' +
'* @link <%= pkg.homepage %>\n' +
'* @copyright <%= pkg.author.name %> <%= grunt.template.today("yyyy") %>\n' +
'* @license Released under the <%= pkg.license %> license.\n' +
'*/\n'
},
clean: {
dist: ['./dist'],
docs: ['./docs'],
"foo-utils": ['./tests/my-api-utils.js']
},
concat: {
dist: {
options: {
banner: "<%= foo.banner %>",
process: function(content){
return content.replace(/@@version/g, pkg.version);
}
},
files: {
"./dist/foo-utils.pre-babel.js": [
"./src/__utils.js",
"./src/is.js",
"./src/fn.js",
"./src/url.js",
"./src/str.js",
"./src/obj.js",
"./src/_utils.js",
"./src/Class.js",
"./src/ClassRegistry.js",
"./src/EventClass.js",
"./src/Timer.js",
"./src/fullscreen.js",
"./src/transition.js"
],
"./dist/foo-utils.core.pre-babel.js": [
"./src/__utils.js",
"./src/is.js",
"./src/fn.js",
"./src/url.js",
"./src/str.js",
"./src/obj.js",
"./src/_utils.js"
],
"./dist/foo-utils.classes.pre-babel.js": [
"./src/Class.js",
"./src/ClassRegistry.js",
"./src/EventClass.js"
],
"./dist/foo-utils.timer.pre-babel.js": [
"./src/Timer.js"
],
"./dist/foo-utils.fullscreen.pre-babel.js": [
"./src/fullscreen.js"
],
"./dist/foo-utils.transition.pre-babel.js": [
"./src/transition.js"
]
}
}
},
babel: {
options: {
presets: [
[
'@babel/preset-env', // Preset to compile your modern JS to ES5.
{
targets: {browsers: BROWSERS_LIST} // Target browser list to support.
}
]
],
ignore: ["./src/polyfills"]
},
dist: {
files: {
"./dist/foo-utils.js": "./dist/foo-utils.pre-babel.js",
"./dist/foo-utils.core.js": "./dist/foo-utils.core.pre-babel.js",
"./dist/foo-utils.classes.js": "./dist/foo-utils.classes.pre-babel.js",
"./dist/foo-utils.timer.js": "./dist/foo-utils.timer.pre-babel.js",
"./dist/foo-utils.fullscreen.js": "./dist/foo-utils.fullscreen.pre-babel.js",
"./dist/foo-utils.transition.js": "./dist/foo-utils.transition.pre-babel.js"
}
}
},
uglify: {
dist: {
options: {
preserveComments: false,
banner: "<%= foo.banner %>"
},
files: {
"./dist/foo-utils.min.js": "./dist/foo-utils.js",
"./dist/foo-utils.core.min.js": "./dist/foo-utils.core.js",
"./dist/foo-utils.classes.min.js": "./dist/foo-utils.classes.js",
"./dist/foo-utils.timer.min.js": "./dist/foo-utils.timer.js",
"./dist/foo-utils.fullscreen.min.js": "./dist/foo-utils.fullscreen.js",
"./dist/foo-utils.transition.min.js": "./dist/foo-utils.transition.js"
}
}
},
"foo-utils": {
options: {
namespace: "MyApi.utils",
dest: "./tests/my-api-utils.js"
}
},
jsdoc: {
"src": ["./readme.md","./src/*.js"],
"options": {
"destination": "./docs",
"recurse": true,
"configure": "jsdoc.json",
"template": "./node_modules/foodoc/template"
}
},
qunit: {
options : {
puppeteer: {
headless: true,
args: [
"--disable-web-security",
"--allow-file-access-from-files"
]
},
timeout: 30000
},
all: ['tests/*.html']
}
});
// Actually load this packages task(s).
grunt.loadTasks('tasks');
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.registerTask('default', ['clean:dist','concat','babel','uglify']);
grunt.registerTask('test', ['clean:foo-utils','foo-utils','qunit','clean:foo-utils']);
grunt.registerTask('document', ['clean:docs','jsdoc']);
};