Browse Source

fix handling of url

Steven Silvester 6 years ago
parent
commit
b36ed3c1df
2 changed files with 12 additions and 5 deletions
  1. 1 4
      dev_mode/index.js
  2. 11 1
      dev_mode/webpack.config.js

+ 1 - 4
dev_mode/index.js

@@ -9,10 +9,7 @@ import {
   PageConfig, URLExt
 } from '@jupyterlab/coreutils';
 
-__webpack_public_path__ = URLExt.join(
-  PageConfig.getOption('baseUrl'),
-  PageConfig.getOption('publicUrl')
-);
+__webpack_public_path__ = PageConfig.getOption('publicUrl');
 
 // This needs to come after __webpack_public_path__ is set.
 require('font-awesome/css/font-awesome.min.css');

+ 11 - 1
dev_mode/webpack.config.js

@@ -75,7 +75,8 @@ function maybeSync(localPath, name, rest) {
 }
 
 /**
- * A WebPack Plugin that copies the assets to the static directory.
+ * A WebPack Plugin that copies the assets to the static directory and
+ * fixes the output of the HTMLWebpackPlugin
  */
 function JupyterLabPlugin() {}
 
@@ -83,6 +84,15 @@ JupyterLabPlugin.prototype.apply = function(compiler) {
   compiler.hooks.afterEmit.tap(
     'JupyterLabPlugin',
     function() {
+      // Fix the template output.
+      var indexPath = path.join(buildDir, 'index.html');
+      var indexData = fs.readFileSync(indexPath, 'utf8');
+      indexData = indexData
+        .split('{{page_config.publicUrl}}/')
+        .join('{{page_config.publicUrl}}');
+      fs.writeFileSync(indexPath, indexData, 'utf8');
+
+      // Copy the static assets.
       var staticDir = jlab.staticDir;
       if (!staticDir) {
         return;