summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-06-28 15:15:50 -0500
committerMike Greiling <mike@pixelcog.com>2017-06-28 15:15:50 -0500
commit5b43aa955737f002be3d197c9f7b4d3374d0ad69 (patch)
treeca14bad39665cabec32ff531f56ddb27983ea3a3
parent8bb2013279a0f9116c01374b55401f3ca0d51c24 (diff)
downloadgitlab-ce-5b43aa955737f002be3d197c9f7b4d3374d0ad69.tar.gz
move webpack publicPath setup earlier in the bootstrap processes to avoid ES module execution order issues
-rw-r--r--app/assets/javascripts/main.js8
-rw-r--r--app/assets/javascripts/webpack.js13
-rw-r--r--app/views/layouts/_head.html.haml2
-rw-r--r--config/webpack.config.js3
4 files changed, 16 insertions, 10 deletions
diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js
index e11d11f87af..a4bcb14b636 100644
--- a/app/assets/javascripts/main.js
+++ b/app/assets/javascripts/main.js
@@ -164,14 +164,6 @@ import './visibility_select';
import './wikis';
import './zen_mode';
-// set url root for webpack async chunks (assumes config.output.publicPath is an absolute path)
-if (gon && gon.relative_url_root) {
- const basePath = gon.relative_url_root.replace(/\/$/, '');
-
- // eslint-disable-next-line camelcase, no-undef
- __webpack_public_path__ = basePath + __webpack_public_path__;
-}
-
// eslint-disable-next-line global-require, import/no-commonjs
if (process.env.NODE_ENV !== 'production') require('./test_utils/');
diff --git a/app/assets/javascripts/webpack.js b/app/assets/javascripts/webpack.js
new file mode 100644
index 00000000000..37420dcafa0
--- /dev/null
+++ b/app/assets/javascripts/webpack.js
@@ -0,0 +1,13 @@
+/**
+ * This is the first script loaded by webpack's runtime. It is used to manually configure
+ * config.output.publicPath to account for relative_url_root settings which cannot be baked-in
+ * to our webpack bundles.
+ */
+
+if (gon && gon.relative_url_root) {
+ // this assumes config.output.publicPath is an absolute path
+ const basePath = gon.relative_url_root.replace(/\/$/, '');
+
+ // eslint-disable-next-line camelcase, no-undef
+ __webpack_public_path__ = basePath + __webpack_public_path__;
+}
diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml
index eabc9a3b01c..a966349523f 100644
--- a/app/views/layouts/_head.html.haml
+++ b/app/views/layouts/_head.html.haml
@@ -36,7 +36,7 @@
= Gon::Base.render_data
- = webpack_bundle_tag "runtime"
+ = webpack_bundle_tag "webpack_runtime"
= webpack_bundle_tag "common"
= webpack_bundle_tag "locale"
= webpack_bundle_tag "main"
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 39e665d5c14..a2e7a93d501 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -71,6 +71,7 @@ var config = {
vue_merge_request_widget: './vue_merge_request_widget/index.js',
test: './test.js',
peek: './peek.js',
+ webpack_runtime: './webpack.js',
},
output: {
@@ -189,7 +190,7 @@ var config = {
// create cacheable common library bundles
new webpack.optimize.CommonsChunkPlugin({
- names: ['main', 'locale', 'common', 'runtime'],
+ names: ['main', 'locale', 'common', 'webpack_runtime'],
}),
],