forked from ModuleLoader/es-module-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
97 lines (94 loc) · 2.73 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
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*\n * <%= pkg.name %> v<%= pkg.version %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
dist: [
'lib/index.js'
]
},
concat: {
dist: {
files: {
'dist/<%= pkg.name %>.src.js': [
'node_modules/when/es6-shim/Promise.js',
'src/polyfill-wrapper-start.js',
'dist/<%= pkg.name %>.js',
'src/polyfill-wrapper-end.js'
],
'dist/<%= pkg.name %>-sans-promises.src.js': [
'src/polyfill-wrapper-start.js',
'dist/<%= pkg.name %>.js',
'src/polyfill-wrapper-end.js'
]
}
}
},
esnext: {
dist: {
src: [
'src/loader.js',
'src/transpiler.js',
'src/system.js'
],
dest: 'dist/<%= pkg.name %>.js'
}
},
'string-replace': {
dist: {
files: {
'dist/<%= pkg.name %>.js': 'dist/<%= pkg.name %>.js'
},
options: {
replacements:[{
pattern: 'var $__Object$getPrototypeOf = Object.getPrototypeOf;\n' +
'var $__Object$defineProperty = Object.defineProperty;\n' +
'var $__Object$create = Object.create;',
replacement: ''
}, {
pattern: '$__Object$getPrototypeOf(SystemLoader.prototype).constructor',
replacement: '$__super'
}]
}
}
},
uglify: {
options: {
banner: '<%= meta.banner %>\n',
compress: {
drop_console: true
},
sourceMap: true
},
dist: {
options: {
banner: '<%= meta.banner %>\n'
},
src: 'dist/<%= pkg.name %>.src.js',
dest: 'dist/<%= pkg.name %>.js'
},
distSansPromises: {
src: 'dist/<%= pkg.name %>-sans-promises.src.js',
dest: 'dist/<%= pkg.name %>-sans-promises.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-esnext');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-string-replace');
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('compile', ['esnext', 'string-replace', 'concat']);
grunt.registerTask('default', [/*'jshint', */'esnext', 'string-replace',
'concat', 'uglify']);
};