Sha256: 35c2c4aed858ab06f5e618ed341db18272a89456281e6955e6fc249c6b81619f

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";

const RawSource = require("webpack-sources").RawSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");

class EvalDevToolModuleTemplatePlugin {
	constructor(sourceUrlComment, moduleFilenameTemplate) {
		this.sourceUrlComment = sourceUrlComment || "\n//# sourceURL=[url]";
		this.moduleFilenameTemplate = moduleFilenameTemplate || "webpack:///[resourcePath]?[loaders]";
	}

	apply(moduleTemplate) {
		moduleTemplate.plugin("module", (source, module) => {
			const content = source.source();
			const str = ModuleFilenameHelpers.createFilename(module, this.moduleFilenameTemplate, moduleTemplate.requestShortener);
			const footer = ["\n",
				ModuleFilenameHelpers.createFooter(module, moduleTemplate.requestShortener),
				this.sourceUrlComment.replace(/\[url\]/g, encodeURI(str).replace(/%2F/g, "/").replace(/%20/g, "_").replace(/%5E/g, "^").replace(/%5C/g, "\\").replace(/^\//, ""))
			].join("\n");
			return new RawSource(`eval(${JSON.stringify(content + footer)});`);
		});
		moduleTemplate.plugin("hash", hash => {
			hash.update("EvalDevToolModuleTemplatePlugin");
			hash.update("2");
		});
	}
}

module.exports = EvalDevToolModuleTemplatePlugin;

Version data entries

10 entries across 6 versions & 3 rubygems

Version Path
ilog-0.4.1 node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
ilog-0.4.0 node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
ilog-0.3.3 node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
optimacms-0.4.3 spec/dummy/node_modules/@rails/webpacker/node_modules/webpack/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
optimacms-0.4.3 spec/dummy/node_modules/@rails/webpacker/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
optimacms-0.4.3 spec/dummy/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
optimacms-0.4.2 spec/dummy/node_modules/@rails/webpacker/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
optimacms-0.4.2 spec/dummy/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
optimacms-0.4.2 spec/dummy/node_modules/@rails/webpacker/node_modules/webpack/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js
cortex-0.1.3 spec/dummy/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js