summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-03-01 02:11:07 -0600
committerMike Greiling <mike@pixelcog.com>2018-03-01 11:29:26 -0600
commit9d9d0105947e4cc23f150135e0c904d6ad31f315 (patch)
tree92c7f7dcf5d1b079e5e39d66832d05d1f8b1ca05
parent4e86a7378cd96ffebfb1c128c9fcb614ee479ffe (diff)
downloadgitlab-ce-9d9d0105947e4cc23f150135e0c904d6ad31f315.tar.gz
migrate sketch_viewer to dynamic import
-rw-r--r--app/assets/javascripts/blob/sketch_viewer.js4
-rw-r--r--app/assets/javascripts/blob/viewer/index.js3
-rw-r--r--app/views/projects/blob/viewers/_sketch.html.haml4
-rw-r--r--config/webpack.config.js1
4 files changed, 5 insertions, 7 deletions
diff --git a/app/assets/javascripts/blob/sketch_viewer.js b/app/assets/javascripts/blob/sketch_viewer.js
index 0640dd26855..2c1c6339fdb 100644
--- a/app/assets/javascripts/blob/sketch_viewer.js
+++ b/app/assets/javascripts/blob/sketch_viewer.js
@@ -1,8 +1,8 @@
/* eslint-disable no-new */
import SketchLoader from './sketch';
-document.addEventListener('DOMContentLoaded', () => {
+export default () => {
const el = document.getElementById('js-sketch-viewer');
new SketchLoader(el);
-});
+};
diff --git a/app/assets/javascripts/blob/viewer/index.js b/app/assets/javascripts/blob/viewer/index.js
index b227cf38920..ac18e6fb9f9 100644
--- a/app/assets/javascripts/blob/viewer/index.js
+++ b/app/assets/javascripts/blob/viewer/index.js
@@ -38,6 +38,9 @@ export default class BlobViewer {
case 'pdf':
initViewer(import(/* webpackChunkName: 'pdf_viewer' */ '../pdf_viewer'));
break;
+ case 'sketch':
+ initViewer(import(/* webpackChunkName: 'sketch_viewer' */ '../sketch_viewer'));
+ break;
default:
break;
}
diff --git a/app/views/projects/blob/viewers/_sketch.html.haml b/app/views/projects/blob/viewers/_sketch.html.haml
index 8fb67c819c1..b4b6492b92f 100644
--- a/app/views/projects/blob/viewers/_sketch.html.haml
+++ b/app/views/projects/blob/viewers/_sketch.html.haml
@@ -1,7 +1,3 @@
-- content_for :page_specific_javascripts do
- = webpack_bundle_tag('common_vue')
- = webpack_bundle_tag('sketch_viewer')
-
.file-content#js-sketch-viewer{ data: { endpoint: blob_raw_path } }
.js-loading-icon.text-center.prepend-top-default.append-bottom-default.js-loading-icon{ 'aria-label' => 'Loading Sketch preview' }
= icon('spinner spin 2x', 'aria-hidden' => 'true');
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 1e181363fc1..acc52fd7234 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -47,7 +47,6 @@ function generateEntries() {
mr_notes: './mr_notes/index.js',
protected_branches: './protected_branches',
registry_list: './registry/index.js',
- sketch_viewer: './blob/sketch_viewer.js',
stl_viewer: './blob/stl_viewer.js',
terminal: './terminal/terminal_bundle.js',
two_factor_auth: './two_factor_auth.js',