This repository was archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.js
172 lines (149 loc) · 4.93 KB
/
main.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
module.exports.init = function(grunt) {
var nameFor = require('./lib/util').nameFor;
// Build a new version of the library
this.registerTask('build', "Builds a distributable version of <%= cfg.name %>", ['clean', 'transpile:amd', 'transpile:commonjs', 'concat:amd', 'concat:browser', 'browser:dist', 'jshint', 'uglify:browser']);
// Build a new version of the library but without naming the files
// using pkg.version
this.registerTask('buildNoVersion',
"Builds a distributable version of <%= cfg.name %>, without naming the file with a version",
['clean', 'transpile:amd', 'transpile:commonjs', 'concat:amdNoVersion', 'concat:browser', 'browser:distNoVersion', 'uglify:browserNoVersion']);
this.registerTask('default', ['build']);
// Build test files
this.registerTask('tests', "Builds the test package", ['concat:deps', 'browserify:tests', 'transpile:testsAmd', 'transpile:testsCommonjs', 'buildTests:dist']);
// Run client-side tests on the command line.
this.registerTask('test', "Runs tests through the command line using PhantomJS", ['build', 'tests', 'connect', 'qunit']);
// Run a server. This is ideal for running the QUnit tests in the browser.
this.registerTask('server', ['build', 'tests', 'connect', 'watch:server']);
// Load tasks from npm
var cwd = process.cwd();
grunt.file.setBase(__dirname); // load tasks relative from grunt-microlib
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-es6-module-transpiler');
// Load Ember Dev tasks
grunt.loadTasks('tasks/');
grunt.file.setBase(cwd); // load tasks relative from project
// Return config to be merged into Grunt config
return {
connect: {
server: {},
options: {
hostname: '0.0.0.0',
port: 8000,
base: '.'
}
},
watch: {
server: {
files: ['lib/**', 'vendor/*', 'test/**/*'],
tasks: ['build', 'tests']
},
},
transpile: {
amd: {
moduleName: nameFor,
type: 'amd',
files: [{
expand: true,
cwd: 'lib/',
src: ['**/*.js'],
dest: 'tmp/',
ext: '.amd.js'
}]
},
commonjs: {
moduleName: nameFor,
type: 'cjs',
files: [{
expand: true,
cwd: 'lib/',
src: ['<%= cfg.barename %>/*.js'],
dest: 'dist/commonjs/',
ext: '.js'
},
{
src: ['lib/<%= cfg.barename %>.js'],
dest: 'dist/commonjs/main.js'
}]
},
testsAmd: {
moduleName: nameFor,
type: 'amd',
src: ['test/test_helpers.js', 'test/tests.js', 'test/tests/**/*_test.js'],
dest: 'tmp/tests.amd.js'
},
testsCommonjs: {
moduleName: nameFor,
type: 'cjs',
src: ['test/test_helpers.js', 'test/tests.js', 'test/tests/**/*_test.js'],
dest: 'tmp/tests.cjs.js'
}
},
uglify: {
browser: {
options: {
mangle: true
},
files: {
'dist/<%= pkg.name %>-<%= pkg.version %>.min.js': ['dist/<%= pkg.name %>-<%= pkg.version %>.js'],
}
},
browserNoVersion: {
options: {
mangle: true
},
files: {
'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js'],
}
}
},
jshint: {
options: {
'jshintrc': '.jshintrc'
},
output: {
src: ['dist/<%= pkg.name %>-<%= pkg.version %>.js']
}
},
clean: ["tmp", "dist"],
concat: {
amd: {
src: ['tmp/<%= cfg.barename %>/**/*.amd.js', 'tmp/<%= cfg.barename %>.amd.js'],
dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.amd.js'
},
amdNoVersion: {
src: ['tmp/<%= cfg.barename %>/**/*.amd.js', 'tmp/<%= cfg.barename %>.amd.js'],
dest: 'dist/<%= pkg.name %>.amd.js'
},
deps: {
src: ['vendor/deps/*.js'],
dest: 'tmp/deps.amd.js'
},
browser: {
src: ['node_modules/grunt-microlib/assets/loader.js', 'tmp/<%= cfg.barename %>/**/*.amd.js', 'tmp/<%= cfg.barename %>.amd.js'],
dest: 'tmp/<%= cfg.barename %>.browser1.js'
},
},
browser: {
dist: {
src: 'tmp/<%= cfg.barename %>.browser1.js',
dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js'
},
distNoVersion: {
src: 'tmp/<%= cfg.barename %>.browser1.js',
dest: 'dist/<%= pkg.name %>.js'
}
},
buildTests: {
dist: {
src: ['node_modules/grunt-microlib/assets/loader.js', 'tmp/tests.amd.js', 'tmp/<%= cfg.barename %>/**/*.amd.js', 'tmp/<%= cfg.barename %>.amd.js'],
dest: 'tmp/tests.js'
}
},
}
};