diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-06-14 23:08:02 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-06-28 21:04:34 +0300 |
commit | 3f3993c3d3da135ef32ba0abbff66d910a189bb6 (patch) | |
tree | c49a93c4ea40f7f397d9c7aabc63b324f219d11d /app | |
parent | b37923235bd67542d8f7a02a08c710b6ef3b339d (diff) |
dynamically set webpack publicPath when relative_url_root enabled
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/main.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index d27b4ec78c6..c8761e8fe63 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -164,6 +164,14 @@ 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/'); |