-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
149 lines (144 loc) · 6.88 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
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
/*
* cd node_modules/ && git clone https://github.com/georgezhang/requirejs-tpl.git
*/
module.exports = function (grunt) {
var module_list = require('./src/georgezhang/build/main');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
requirejs: {
compile: {
options: {
baseUrl: 'src/georgezhang/public/js',
include: module_list,
out: 'dest/georgezhang/public/js/mainnote.js',
paths: {
'jquery': 'empty:',
'autosize': 'empty:',
'bootstrap': 'empty:',
'fastclick': 'empty:',
'bootstrap-switch': 'empty:',
'bootstrap-tagsinput': 'empty:',
'validator': 'empty:',
'notify': 'empty:',
'templates': '../templates',
'tpl': '../../build/tpl',
'underscore': '../../build/underscore',
'text': '../../build/text',
'ckeditor-core': 'empty:',
'ckeditor-jquery': 'empty:',
'typeahead': 'empty:',
'bloodhound': 'empty:',
'Promise': 'empty:',
'fineuploader': 'empty:',
},
shim: {
underscore: {
exports: '_'
}
},
stubModules: ['underscore', 'text'],
removeCombined: true,
inlineText: true,
preserveLicenseComments: false,
optimize: 'none',
onModuleBundleComplete: function (data) {
var replace = require('replace');
replace({
regex: /define\('(text|underscore)',{.*?}\);/g,
replacement: '',
paths: [data.path],
recursive: false,
silent: false,
});
},
},
},
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
options: {
sourceMap: true,
},
files: {
'build/mainnote.min.js': ['build/mainnote.js'],
}
},
},
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
target: {
files: [{
src: ['dest/georgezhang/public/css/*.css'],
dest: 'build/mainnote.min.css',
}
],
},
},
jasmine: {
requirejs: {
src: 'src/georgezhang/public/js/*.js',
options: {
specs: 'test/specs/requirejs/*Spec.js',
helpers: 'spec/*Helper.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfigFile: 'src/georgezhang/public/js/config.js',
requireConfig: {
baseUrl: 'src/georgezhang/public/js',
paths: {
'jquery': 'http://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min',
'autosize': 'http://cdnjs.cloudflare.com/ajax/libs/autosize.js/3.0.8/autosize.min',
'bootstrap': 'http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min',
'fastclick': 'http://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min',
'bootstrap-switch': 'http://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min',
'bootstrap-tagsinput': 'http://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.min',
'underscore': 'http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min',
'text': 'http://cdnjs.cloudflare.com/ajax/libs/require-text/2.0.12/text.min',
'jasmine-jquery': '../../../../bower_components/jasmine-jquery/lib/jasmine-jquery',
'validator': 'http://cdnjs.cloudflare.com/ajax/libs/validator/5.2.0/validator.min',
'notify': 'http://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.min',
'ckeditor-core': 'http://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.5.9/ckeditor',
'ckeditor-jquery': 'http://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.5.9/adapters/jquery',
'typeahead': 'http://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.jquery.min',
'bloodhound': 'http://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/bloodhound.min',
'Promise': 'http://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.1/bluebird.min',
'fineuploader': 'http://cdnjs.cloudflare.com/ajax/libs/file-uploader/5.11.7/jquery.fine-uploader/jquery.fine-uploader.min',
},
shim: {
'jasmine-jquery': {
deps: ['jquery'],
exports: 'jasmine-jquery'
}
},
},
}
}
}
},
watch: {
all: {
files: ['test/specs/**/*Spec.js', 'src/georgezhang/public/js/*.js'],
tasks: ['test'],
options: {
spawn: false,
},
},
},
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
// Default task(s).
grunt.registerTask('default', ['requirejs', 'uglify', 'cssmin']);
grunt.registerTask('test', ['jasmine:requirejs']);
};