forked from etsy/411
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
202 lines (194 loc) · 8.45 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
app: {
options: {
shadow: true, //'inner'
unused: false, //'vars'
curly: false, //true
eqeqeq: false, //true
freeze: true,
futurehostile: true,
latedef: true,
undef: true,
nonbsp: true,
sub: true,
loopfunc: true,
newcap: false,
globalstrict: true,
browser: true,
devel: true,
jquery: true,
predef: ['require', 'define', 'requirejs', 'Notification']
},
src: [
'htdocs/assets/js/**/*.js',
'!htdocs/assets/js/templates.compiled.js',
'!htdocs/assets/js/libs/**/*.js'
],
},
},
requirejs: {
js: {
options: {
baseUrl: 'htdocs/assets/js',
removeCombined: true,
dir: 'htdocs/dist/js',
wrap: true,
optimize: 'uglify2',
paths: {
jquery: 'libs/jquery',
uri: 'libs/uri',
underscore: 'libs/underscore',
backbone: 'libs/backbone',
bootstrap: 'libs/bootstrap',
routefilter: 'libs/backbone.routefilter',
handlebars: 'libs/handlebars',
select2: 'libs/select2',
tablesorter: 'libs/tablesorter',
moment: 'libs/moment',
"moment-timezone": 'libs/moment-timezone',
autosize: 'libs/autosize',
dragula: 'libs/dragula',
mousetrap: 'libs/mousetrap',
datetimepicker: 'libs/datetimepicker',
chartjs: 'libs/chart',
codemirror: 'libs/codemirror',
text: 'libs/text',
false: 'libs/false',
templates: 'templates.compiled',
data_json: 'empty:',
},
map: {
uri: {
punycode: 'libs/false',
IPv6: 'libs/false',
SecondLevelDomains: 'libs/false',
}
},
modules: [
{name: 'main'}
],
stubModules: ['punycode', 'IPv6', 'SecondLevelDomains'],
preserveLicenseComments: true,
generateSourceMaps: false,
useStrict: true
}
},
css: {
options: {
keepBuildDir: false,
optimizeCss: "standard",
cssIn: "htdocs/assets/css/main.css",
out: "htdocs/dist/css/main.css"
}
}
},
handlebars: {
app: {
files: {
"htdocs/assets/js/templates.compiled.js": ["htdocs/assets/templates/**/*.html"]
},
options: {
amd: true,
processName: function(filePath) {
return filePath.replace(/^htdocs\/assets\/templates\//, '').replace(/\.html$/, '');
}
}
}
},
copy: {
deps: {
files: [
// {nonull: true, src: 'bower_components/bootstrap/dist/css/bootstrap.css', dest: 'htdocs/assets/css/bootstrap.css'},
{nonull: true, src: 'bower_components/dragula.js/dist/dragula.css', dest: 'htdocs/assets/css/dragula.css'},
{nonull: true, src: 'bower_components/bootswatch/slate/bootstrap.css', dest: 'htdocs/assets/css/bootstrap.css'},
{nonull: true, src: 'bower_components/select2/select2.css', dest: 'htdocs/assets/css/select2.css'},
{nonull: true, src: 'bower_components/select2-bootstrap3-css/select2-bootstrap.css', dest: 'htdocs/assets/css/select2-bootstrap.css'},
{nonull: true, src: 'bower_components/jquery.tablesorter/css/theme.bootstrap.css', dest: 'htdocs/assets/css/tablesorter-bootstrap.css' },
{nonull: true, src: 'bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css', dest: 'htdocs/assets/css/datetimepicker.css' },
{nonull: true, src: 'bower_components/codemirror/lib/codemirror.css', dest: 'htdocs/assets/css/codemirror.css'},
{expand: true, cwd: 'bower_components/bootstrap/dist/fonts/', nonull: true, src: '*', dest: 'htdocs/assets/fonts/' },
{expand: true, cwd: 'bower_components/select2/', nonull: true, src: '*.{png,gif}', dest: 'htdocs/assets/imgs/' },
{nonull: true, src: 'bower_components/dragula.js/dist/dragula.js', dest: 'htdocs/assets/js/libs/dragula.js'},
{nonull: true, src: 'bower_components/autosize/dist/autosize.js', dest: 'htdocs/assets/js/libs/autosize.js' },
{nonull: true, src: 'bower_components/bootstrap/dist/js/bootstrap.js', dest: 'htdocs/assets/js/libs/bootstrap.js'},
{expand: true, cwd: 'bower_components/handlebars/', nonull: true, src: '{handlebars,handlebars.runtime}.js', dest: 'htdocs/assets/js/libs/'},
{nonull: true, src: 'bower_components/codemirror/lib/codemirror.js', dest: 'htdocs/assets/js/libs/codemirror.js'},
{nonull: true, src: 'bower_components/Chart.js/dist/Chart.js', dest: 'htdocs/assets/js/libs/chart.js'},
{nonull: true, src: 'bower_components/jquery/dist/jquery.js', dest: 'htdocs/assets/js/libs/jquery.js'},
{nonull: true, src: 'bower_components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js', dest: 'htdocs/assets/js/libs/datetimepicker.js'},
{nonull: true, src: 'bower_components/select2/select2.js', dest: 'htdocs/assets/js/libs/select2.js'},
{nonull: true, src: 'bower_components/jquery.tablesorter/dist/js/jquery.tablesorter.combined.js', dest: 'htdocs/assets/js/libs/tablesorter.js'},
{nonull: true, src: 'bower_components/requirejs/require.js', dest: 'htdocs/assets/js/libs/require.js'},
{nonull: true, src: 'bower_components/underscore/underscore.js', dest: 'htdocs/assets/js/libs/underscore.js'},
{nonull: true, src: 'bower_components/requirejs-text/text.js', dest: 'htdocs/assets/js/libs/text.js'},
{nonull: true, src: 'bower_components/mousetrap/mousetrap.js', dest: 'htdocs/assets/js/libs/mousetrap.js'},
{nonull: true, src: 'bower_components/uri.js/src/URI.js', dest: 'htdocs/assets/js/libs/uri.js'},
{nonull: true, src: 'bower_components/backbone/backbone.js', dest: 'htdocs/assets/js/libs/backbone.js'},
{nonull: true, src: 'bower_components/routefilter/dist/backbone.routefilter.js', dest: 'htdocs/assets/js/libs/backbone.routefilter.js'},
{nonull: true, src: 'bower_components/moment/moment.js', dest: 'htdocs/assets/js/libs/moment.js'},
{nonull: true, src: 'bower_components/moment-timezone/builds/moment-timezone-with-data.js', dest: 'htdocs/assets/js/libs/moment-timezone.js'},
{nonull: true, src: 'bower_components/false/false.js', dest: 'htdocs/assets/js/libs/false.js'},
],
},
app: {
files: [
{expand: true, cwd: 'htdocs/assets', src: ['imgs/**', 'fonts/*'], dest: 'htdocs/dist', filter: 'isFile'},
{expand: true, cwd: 'htdocs', src: ['index-src.html'], dest: 'htdocs'},
]
},
index: {
files: [
{src: 'htdocs/index-src.html', dest: 'htdocs/index.html'}
]
},
},
sed: {
app: {
path: 'htdocs/dist/js/main.js',
pattern: '/assets/',
replacement: '/dist/',
},
select2: {
path: 'htdocs/assets/css/select2.css',
pattern: /url\('/g,
replacement: "url('../imgs/",
},
dev: {
path: 'htdocs/index.html',
pattern: 'ASSET_DIR',
replacement: 'assets',
},
prod: {
path: 'htdocs/index.html',
pattern: 'ASSET_DIR',
replacement: 'dist',
}
},
run: {
docs: {
cmd: 'vendor/bin/phpdoc',
args: ['run', '-d', 'phplib', '-t', 'phpdoc']
},
tests: {
cmd: 'vendor/bin/phpunit',
args: ['-c', 'tests/phpunit.xml'],
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-sed');
grunt.registerTask('deps', ['copy:deps']);
grunt.registerTask('default', ['prod']);
// Public
grunt.registerTask('dev', ['deps', 'sed:select2', 'copy:index', 'sed:dev']);
grunt.registerTask('prod', ['deps', 'jshint:app', 'handlebars:app', 'copy:app', 'sed:select2', 'requirejs:js', 'requirejs:css', 'sed:app', 'copy:index', 'sed:prod']);
grunt.registerTask('tests', ['run:tests']);
grunt.registerTask('docs', ['run:docs']);
};