From 929d669e1d55436dd212eb985144a16337b8fc1c Mon Sep 17 00:00:00 2001 From: SirStendec Date: Thu, 5 Apr 2018 15:44:47 -0400 Subject: [PATCH] Use the webpack externals configuration directive to prevent bundling any additional copies of Vue. This is basically to make sure the main menu doesn't misbehave. Modules using vue may need to add the vue module to their load_requires now, as demonstrated in main_menu. If importing .vue files individually, this likely isn't necessary. --- src/modules/main_menu/index.js | 2 ++ src/utilities/vue.js | 2 +- webpack.common.js | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/main_menu/index.js b/src/modules/main_menu/index.js index a60f4500..3fe5f899 100644 --- a/src/modules/main_menu/index.js +++ b/src/modules/main_menu/index.js @@ -28,6 +28,8 @@ export default class MainMenu extends Module { this.inject('site'); this.inject('vue'); + this.load_requires = ['vue']; + //this.should_enable = true; this._settings_tree = null; diff --git a/src/utilities/vue.js b/src/utilities/vue.js index 01a21a4b..4e5e0c45 100644 --- a/src/utilities/vue.js +++ b/src/utilities/vue.js @@ -17,7 +17,7 @@ export class Vue extends Module { } async onLoad() { - const Vue = this.Vue = (await import(/* webpackChunkName: "vue" */ 'vue')).default, + const Vue = window.ffzVue = this.Vue = (await import(/* webpackChunkName: "vue" */ 'vue')).default, components = this._components; this.component((await import(/* webpackChunkName: "vue" */ 'src/std-components/index.js')).default); diff --git a/webpack.common.js b/webpack.common.js index 39fefdd4..4b158f0f 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -16,6 +16,13 @@ module.exports = { utilities: path.resolve(__dirname, 'src/utilities/') } }, + externals: [ + function(context, request, callback) { + if ( request === 'vue' && ! /utilities/.test(context) ) + return callback(null, 'root ffzVue'); + callback(); + } + ], output: { chunkFilename: '[name].[chunkhash].js', path: path.resolve(__dirname, 'dist'),