/
index.js
39 lines (24 loc) · 854 Bytes
/
index.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
/**
superloader
Copyright 2016 Brandon Carl
MIT Licensed
*/
var path = require("path"),
Pipemaker = require("pipemaker"),
Superloader;
/**
Universal loader for webpack.
@param {String} content Content to progress.
**/
Superloader = module.exports = function Superloader(content) {
var ext = path.parse(this.resourcePath).ext.replace(/^\./, ""),
next = this.async();
// Add pipeline if necessary
if (!Superloader.pipelines.hasPipeline(ext))
Superloader.pipelines.addPipeline(ext);
// The pipemaker pipeline will compile based on file extension (we remove the leading ".")
Superloader.pipelines.compile(ext, content, {}, next);
};
// Expose pipemaker object. This allows additional/removal of pipemaker, as well as querying
// current configuration.
Superloader.pipelines = new Pipemaker();