From 2d1fb111344d567b51617b65a403345f401f7b81 Mon Sep 17 00:00:00 2001 From: code-mcx <1827939333@qq.com> Date: Tue, 27 Nov 2018 21:49:33 +0800 Subject: [PATCH] fix(webpack-plugin): fix TypeError when set writeToDisk true (#170) --- packages/webpack-plugin/src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/webpack-plugin/src/index.js b/packages/webpack-plugin/src/index.js index d8c194c9..03640efa 100644 --- a/packages/webpack-plugin/src/index.js +++ b/packages/webpack-plugin/src/index.js @@ -4,6 +4,9 @@ const fs = require('fs') class LoadablePlugin { constructor({ filename = 'loadable-stats.json', writeToDisk = false } = {}) { this.opts = { filename, writeToDisk } + + // The Webpack compiler instance + this.compiler = null } handleEmit = (hookCompiler, callback) => { @@ -104,6 +107,8 @@ class LoadablePlugin { } apply(compiler) { + this.compiler = compiler + // Add a custom output.jsonpFunction: __LOADABLE_LOADED_CHUNKS__ compiler.options.output.jsonpFunction = '__LOADABLE_LOADED_CHUNKS__'