From 80126228b216540b634cc9de3599826f02ddcc4c Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 4 Apr 2018 16:37:26 +0800 Subject: [PATCH] remove temporary fix for html-webpack-plugin It has been fixed in: vue-loader #8626739c --- lib/builder/webpack/base.js | 4 --- lib/builder/webpack/client.js | 4 +-- lib/builder/webpack/utils/lodash-loader.js | 36 ---------------------- 3 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 lib/builder/webpack/utils/lodash-loader.js diff --git a/lib/builder/webpack/base.js b/lib/builder/webpack/base.js index e2d941a5e0..8cd6a29406 100644 --- a/lib/builder/webpack/base.js +++ b/lib/builder/webpack/base.js @@ -255,10 +255,6 @@ export default class WebpackBaseConfig { modules: webpackModulesDir }, resolveLoader: { - alias: { - // TODO: Move to an external package? - lodash: path.resolve(this.options.nuxtDir, 'lib/builder/webpack/utils/lodash-loader.js') - }, modules: webpackModulesDir }, module: { diff --git a/lib/builder/webpack/client.js b/lib/builder/webpack/client.js index 0fd1a98083..f5fd39a682 100644 --- a/lib/builder/webpack/client.js +++ b/lib/builder/webpack/client.js @@ -31,7 +31,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig { plugins.push( new HTMLPlugin({ filename: 'index.ssr.html', - template: 'lodash!' + this.options.appTemplatePath, + template: this.options.appTemplatePath, inject: false // Resources will be injected using bundleRenderer }) ) @@ -40,7 +40,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig { plugins.push( new HTMLPlugin({ filename: 'index.spa.html', - template: 'lodash!' + this.options.appTemplatePath, + template: this.options.appTemplatePath, inject: true, chunksSortMode: 'dependency' }), diff --git a/lib/builder/webpack/utils/lodash-loader.js b/lib/builder/webpack/utils/lodash-loader.js deleted file mode 100644 index d574732f9e..0000000000 --- a/lib/builder/webpack/utils/lodash-loader.js +++ /dev/null @@ -1,36 +0,0 @@ -const _ = require('lodash') -const loaderUtils = require('loader-utils') - -module.exports = function (source) { - if (this.cacheable) { - this.cacheable() - } - - // The following part renders the tempalte with lodash as aminimalistic loader - // - // Get templating options - const options = this.query !== '' ? 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 - const template = _.template(source, _.defaults(options, { variable: 'data' })) - // All templateVariables which should be available - // @see HtmlWebpackPlugin.prototype.executeTemplate - const 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 + ')();' + - '}' -}