aboutsummaryrefslogtreecommitdiff
path: root/node_modules/html-webpack-plugin/lib/loader.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
commitcc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch)
tree92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/html-webpack-plugin/lib/loader.js
parent3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff)
remove node_modules
Diffstat (limited to 'node_modules/html-webpack-plugin/lib/loader.js')
-rw-r--r--node_modules/html-webpack-plugin/lib/loader.js51
1 files changed, 0 insertions, 51 deletions
diff --git a/node_modules/html-webpack-plugin/lib/loader.js b/node_modules/html-webpack-plugin/lib/loader.js
deleted file mode 100644
index 6b8bd0d8e..000000000
--- a/node_modules/html-webpack-plugin/lib/loader.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This loader renders the template with underscore if no other loader was found */
-'use strict';
-
-var _ = require('lodash');
-var loaderUtils = require('loader-utils');
-
-module.exports = function (source) {
- if (this.cacheable) {
- this.cacheable();
- }
- var allLoadersButThisOne = this.loaders.filter(function (loader) {
- // Loader API changed from `loader.module` to `loader.normal` in Webpack 2.
- return (loader.module || loader.normal) !== module.exports;
- });
- // This loader shouldn't kick in if there is any other loader
- if (allLoadersButThisOne.length > 0) {
- return source;
- }
- // Skip .js files
- if (/\.js$/.test(this.resourcePath)) {
- return source;
- }
-
- // The following part renders the tempalte with lodash as aminimalistic loader
- //
- // Get templating options
- var options = loaderUtils.parseQuery(this.query);
- // Webpack 2 does not allow with() statements, which lodash templates use to unwrap
- // the parameters passed to the compiled template inside the scope. We therefore
- // need to unwrap them ourselves here. This is essentially what lodash does internally
- // To tell lodash it should not use with we set a variable
- var template = _.template(source, _.defaults(options, { variable: 'data' }));
- // All templateVariables which should be available
- // @see HtmlWebpackPlugin.prototype.executeTemplate
- var templateVariables = [
- 'compilation',
- 'webpack',
- 'webpackConfig',
- 'htmlWebpackPlugin'
- ];
- return 'var _ = require(' + loaderUtils.stringifyRequest(this, require.resolve('lodash')) + ');' +
- 'module.exports = function (templateParams) {' +
- // Declare the template variables in the outer scope of the
- // lodash template to unwrap them
- templateVariables.map(function (variableName) {
- return 'var ' + variableName + ' = templateParams.' + variableName;
- }).join(';') + ';' +
- // Execute the lodash template
- 'return (' + template.source + ')();' +
- '}';
-};