forked from bigskysoftware/intercooler-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
102 lines (91 loc) · 4.42 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
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
umd: {
intercooler: {
options: {
src: 'src/intercooler.js',
dest: 'www/release/intercooler-<%= pkg.version %>.js',
// amdModuleId if commented out defaults to the filename without the `.js`, since Intercooler keeps copies of
// older Intercoolers in its www/release directory, keep this commented to prevent conflicts with older ones.
// amdModuleId: 'intercooler', // The `require('intercooler')` id used to import, lower-case name is usual
objectToExport: 'Intercooler',
globalAlias: 'Intercooler', // Always force an Intercooler object
deps: {
'default': [{jquery: '$'}],
amd: [{jquery: '$'}],
cjs: [{jquery: '$'}],
global: [{jQuery: '$'}] // Capital Q because that is how jQuery is in the global scope unlike the others
}
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'www/release/intercooler-<%= pkg.version %>.js',
dest: 'www/release/intercooler-<%= pkg.version %>.min.js'
}
},
"regex-replace": {
"update-test-ref": { //specify a target with any name
src: ['www/release/unit-tests-<%= pkg.version %>.html',
'www/release/jQuery1_unit-tests-<%= pkg.version %>.html',
'www/release/jQuery2_unit-tests-<%= pkg.version %>.html',
'www/release/zepto_unit-tests-<%= pkg.version %>.html'],
actions: [
{
name: 'lib ref',
search: "../src/intercooler.js",
replace: './intercooler-<%= pkg.version %>.js',
flags: 'g'
}
]
},
"update-test-ref-2": { //specify a target with any name
src: ['www/release/unit-tests-<%= pkg.version %>.min.html'],
actions: [
{
name: 'lib ref',
search: "../src/intercooler.js",
replace: './intercooler-<%= pkg.version %>.min.js',
flags: 'g'
}
]
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-regex-replace');
grunt.loadNpmTasks('grunt-umd');
grunt.registerTask('dist', "Copy Distribution files", function () {
grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.js', 'dist/intercooler.js');
grunt.file.copy('www/release/intercooler-' + grunt.config.get('pkg').version + '.min.js', 'dist/intercooler.min.js');
});
grunt.registerTask('release', "Releases a new version of the library", function () {
grunt.file.copy("src/intercooler-debugger.js", 'www/release/intercooler-debugger.js');
grunt.file.copy("test/lib/blanket.min.js", 'www/release/blanket.min.js');
grunt.file.copy("test/lib/jquery.mockjax-2.2.1.js", 'www/release/lib/jquery.mockjax-2.2.1.js');
grunt.file.copy("test/lib/jquery-1.10.2.js", 'www/release/lib/jquery-1.10.2.js');
grunt.file.copy("test/lib/jquery-2.2.4.js", 'www/release/lib/jquery-2.2.4.js');
grunt.file.copy("test/lib/jquery-3.1.1.js", 'www/release/lib/jquery-3.1.1.js');
grunt.file.copy("test/lib/zepto.mockjax-1.2.0.js", 'www/release/lib/zepto.mockjax-1.2.0.js');
grunt.file.copy("test/lib/zepto.data-1.2.0.js", 'www/release/lib/zepto.data-1.2.0.js');
grunt.file.copy("test/lib/zepto-1.2.0.min.js", 'www/release/lib/zepto-1.2.0.min.js');
grunt.file.copy("test/unit_tests.html", 'www/release/unit-tests-' + grunt.config.get('pkg').version + '.html');
grunt.file.copy("test/unit_tests.html", 'www/release/unit-tests-' + grunt.config.get('pkg').version + '.min.html');
grunt.file.copy("test/jQuery2_unit_tests.html", 'www/release/jQuery2_unit-tests-' + grunt.config.get('pkg').version + '.html');
grunt.file.copy("test/jQuery1_unit_tests.html", 'www/release/jQuery1_unit-tests-' + grunt.config.get('pkg').version + '.html');
grunt.file.copy("test/zepto_unit_tests.html", 'www/release/zepto_unit-tests-' + grunt.config.get('pkg').version + '.html');
grunt.task.run('umd:intercooler');
grunt.task.run('uglify');
grunt.task.run('regex-replace');
grunt.task.run('dist');
});
// Default task(s).
grunt.registerTask('default', ['release']);
};