Commit eb548e6e authored by Mike Greiling's avatar Mike Greiling

adjust IDE page loading config to ensure web workers are not loaded cross-origin

parent b2d90ea1
...@@ -4,7 +4,9 @@ import ide from './components/ide.vue'; ...@@ -4,7 +4,9 @@ import ide from './components/ide.vue';
import store from './stores'; import store from './stores';
import router from './ide_router'; import router from './ide_router';
function initIde(el) { Vue.use(Translate);
export function initIde(el) {
if (!el) return null; if (!el) return null;
return new Vue({ return new Vue({
...@@ -26,8 +28,9 @@ function initIde(el) { ...@@ -26,8 +28,9 @@ function initIde(el) {
}); });
} }
const ideElement = document.getElementById('ide'); export function resetServiceWorkersPublicPath() {
// tell webpack to load assets from origin so that web workers don't break
Vue.use(Translate); const relativeRootPath = (gon && gon.relative_url_root) || '';
const webpackAssetPath = `${relativeRootPath}/assets/webpack/`;
initIde(ideElement); __webpack_public_path__ = webpackAssetPath; // eslint-disable-line camelcase
}
import { initIde, resetServiceWorkersPublicPath } from '~/ide/index';
document.addEventListener('DOMContentLoaded', () => {
const ideElement = document.getElementById('ide');
if (ideElement) {
resetServiceWorkersPublicPath();
initIde(ideElement);
}
});
- @body_class = 'ide' - @body_class = 'ide'
- page_title 'IDE' - page_title 'IDE'
- content_for :page_specific_javascripts do
= webpack_bundle_tag 'ide', force_same_domain: true
#ide.ide-loading{ data: {"empty-state-svg-path" => image_path('illustrations/multi_file_editor_empty.svg'), #ide.ide-loading{ data: {"empty-state-svg-path" => image_path('illustrations/multi_file_editor_empty.svg'),
"no-changes-state-svg-path" => image_path('illustrations/multi-editor_no_changes_empty.svg'), "no-changes-state-svg-path" => image_path('illustrations/multi-editor_no_changes_empty.svg'),
"committed-state-svg-path" => image_path('illustrations/multi-editor_all_changes_committed_empty.svg') } } "committed-state-svg-path" => image_path('illustrations/multi-editor_all_changes_committed_empty.svg') } }
......
...@@ -57,7 +57,6 @@ function generateEntries() { ...@@ -57,7 +57,6 @@ function generateEntries() {
const manualEntries = { const manualEntries = {
default: defaultEntries, default: defaultEntries,
raven: './raven/index.js', raven: './raven/index.js',
ide: './ide/index.js',
}; };
return Object.assign(manualEntries, autoEntries); return Object.assign(manualEntries, autoEntries);
...@@ -75,6 +74,7 @@ const config = { ...@@ -75,6 +74,7 @@ const config = {
publicPath: '/assets/webpack/', publicPath: '/assets/webpack/',
filename: IS_PRODUCTION ? '[name].[chunkhash].bundle.js' : '[name].bundle.js', filename: IS_PRODUCTION ? '[name].[chunkhash].bundle.js' : '[name].bundle.js',
chunkFilename: IS_PRODUCTION ? '[name].[chunkhash].chunk.js' : '[name].chunk.js', chunkFilename: IS_PRODUCTION ? '[name].[chunkhash].chunk.js' : '[name].chunk.js',
globalObject: 'this', // allow HMR and web workers to play nice
}, },
optimization: { optimization: {
...@@ -129,15 +129,7 @@ const config = { ...@@ -129,15 +129,7 @@ const config = {
}, },
{ {
test: /\_worker\.js$/, test: /\_worker\.js$/,
use: [ use: ['worker-loader', 'babel-loader'],
{
loader: 'worker-loader',
options: {
inline: true,
},
},
{ loader: 'babel-loader' },
],
}, },
{ {
test: /\.(worker(\.min)?\.js|pdf|bmpr)$/, test: /\.(worker(\.min)?\.js|pdf|bmpr)$/,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment