-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
115 lines (100 loc) · 2.94 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
server: {
options: {
port: 3000,
keepalive: true
}
}
},
mocha: {
// Test all files ending in .html anywhere inside the test directory.
browser: ['test/**/*.html'],
options: {
reporter: 'Nyan', // Duh!
run: true
}
},
handlebars: {
compile: {
amd: true,
files: {
'src/template/templates.js': 'src/template/**/*.hbs'
}
}
},
clean: {
build: ['build/js/*', '!build/js/app.js'],
dist: ['dist']
},
copy: {
main: {
expand: true,
cwd: 'src',
src: '**',
dest: 'build/js'
},
libs: {
files: [
{ expand:true, src: ['node_modules/handlebars/dist/handlebars.js'], dest:'build/js/libs/', flatten: true },
{ expand:true, src: ['node_modules/handlebars/dist/handlebars.runtime.js'], dest:'build/js/libs/', flatten: true },
{ expand:true, src: ['node_modules/requirejs/require.js'], dest:'build/js/libs/', flatten: true },
{ expand:true, src: ['libs/hbars.js'], dest:'build/js/libs/', flatten: true },
{ expand:true, src: ['libs/text.js'], dest:'build/js/libs/', flatten: true }
]
}
},
requirejs: {
compile: {
options: {
// Assume your scripts are in a subdirectory under this path.
appDir: 'src',
// By default, all modules are located relative to this path.
baseUrl: '.',
// Location of the runtime config be read for the build.
mainConfigFile: 'src/build.js',
//The directory path to save the output.
dir: 'dist',
// If you do not want uglifyjs optimization.
optimize: 'uglify',
// Inlines any text! dependencies, to avoid separate requests.
inlineText: true,
// Modules to stub out in the optimized file.
stubModules: ['text', 'hbars'],
// Files combined into a build layer will be removed from the output folder.
removeCombined: true,
writeBuildTxt: false,
// This option will turn off the auto-preservation.
preserveLicenseComments: false,
//List the modules that will be optimized.
modules: [
{
name: "main" // main config file
}
]
}
}
}
});
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('start', 'Run local server', function() {
grunt.task.run('connect');
});
grunt.registerTask('build', 'Build files for test', function() {
grunt.task.run('clean:build');
grunt.task.run('copy:libs');
grunt.task.run('copy:main');
});
grunt.registerTask('test', 'Run Mocha tests.', function() {
// If not --test option is specified, run all tests.
var test_case = grunt.option('test') || '**/*';
grunt.config.set('mocha.browser', ['test/' + test_case + '.html']);
grunt.task.run('mocha');
});
};