1 | var path = require("path");
|
2 |
|
3 | module.exports = function(bundle){
|
4 | if(bundle.source.map) {
|
5 | var filename = path.basename(removePlugin(bundleName(bundle))) + "." +
|
6 | bundle.buildType;
|
7 | bundle.source.code += wrap(filename, bundle.buildType);
|
8 | }
|
9 | };
|
10 |
|
11 | var pluginExp = /\..+!$/;
|
12 | function removePlugin(name) {
|
13 | return name.replace(pluginExp, "");
|
14 | }
|
15 |
|
16 | function bundleName(bundle) {
|
17 | var name = bundle.name || bundle.bundles[0] || bundle.nodes[0].load.name;
|
18 | return name .replace("bundles/", "").replace(/\..+!/, "");
|
19 | }
|
20 |
|
21 | function wrap(filename, buildType) {
|
22 | switch(buildType) {
|
23 | case "css":
|
24 | return "\n/*# sourceMappingURL=" + filename + ".map */";
|
25 | default:
|
26 | return "\n//# sourceMappingURL=" + filename + ".map";
|
27 | }
|
28 | }
|