aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/loaders/scoped-loader.js
blob: 1be58a4af85c75d97a160841191030705eedb62f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const path = require("path");

const scripts = require(path.resolve(process.env.SOURCE_DIR, "scripts.json"));

const getScriptType = scriptName => {
	for (const scriptType in scripts) {
		if (scripts[scriptType][scriptName]) {
			return scriptType;
		}
	}
	return "undefined_script";
};

module.exports = function (source) {
	return `/*<--\t${getScriptType(path.basename(this.resourcePath))}\t-->*/
(() => {\n${source}\n})();
/*<---->*/`
};