-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (21 loc) · 687 Bytes
/
index.js
File metadata and controls
31 lines (21 loc) · 687 Bytes
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
var fs = require('fs');
var path = require('path');
var loaderUtils = require('loader-utils');
var DEFAULT_WEBSITE = 'https://gabrielecirulli.github.io/2048/';
module.exports = function inject( src ) {
this.cacheable && this.cacheable();
var callback = this.async();
var query = loaderUtils.parseQuery(this.query);
var website = query.website || DEFAULT_WEBSITE;
fs.readFile( path.join( __dirname, './client.js' ), 'utf-8', function( err, contents ) {
if( err ) {
throw err;
}
var built = [
'var website = "' + website + '";',
src,
contents,
].join('\n');
callback( null, built );
});
}