sebavan 6 anni fa
parent
commit
dfcbcdac17

+ 13 - 3
Tools/Gulp/tasks/gulpTasks-libraries.js

@@ -43,12 +43,22 @@ var buildExternalLibrariesMultiEntry = function(libraries, settings, isMin) {
 
     // Webpack Config.
     var wpConfig = require(settings.build.webpack);
-    // Create multi entry list.
-    wpConfig.entry = { };
+
+    // Map Output
+    var rootPath = path.resolve(__dirname, "../../../");
+    var absoluteSrc = path.resolve(__dirname, "../", settings.build.srcDirectory);
     wpConfig.output.devtoolModuleFilenameTemplate = (info) => {
-        return `webpack://${info.namespace}/${info.resourcePath.replace('../Tools/Gulp/../../', '')}`;
+        info.resourcePath = path.normalize(info.resourcePath);
+
+        if (!path.isAbsolute(info.resourcePath)) {
+            info.resourcePath = path.join(absoluteSrc, info.resourcePath);
+        }
+
+        return `webpack://BABYLONJS/${path.relative(rootPath, info.resourcePath).replace(/\\/g, "/")}`;
     };
 
+    // Create multi entry list.
+    wpConfig.entry = { };
     for (let library of settings.libraries) {
         let name = library.output.replace(isMinOutputName ? ".min.js" : ".js", "");
         wpConfig.entry[name] = path.resolve(wpConfig.context, library.entry);

+ 21 - 9
Tools/Gulp/tasks/gulpTasks-watch.js

@@ -2,6 +2,7 @@
 var gulp = require("gulp");
 var webpack = require('webpack');
 var webpackStream = require("webpack-stream");
+var path = require("path");
 var processShaders = require("../helpers/gulp-processShaders");
 var uncommentShaders = require('../helpers/gulp-removeShaderComments');
 
@@ -16,6 +17,7 @@ gulp.task("watch", function startWatch() {
 
     config.modules.map(function(module) {
         var settings = config[module].build;
+        var isCore = config[module].isCore;
         if (settings && settings.webpack) {
             for (var index = 0; index < config[module].libraries.length; index++) {
                 var library = config[module].libraries[index];
@@ -23,22 +25,32 @@ gulp.task("watch", function startWatch() {
                     continue;
                 }
 
-                let wpconfig = require(settings.webpack);
+                let wpConfig = require(settings.webpack);
                 // watch on.
-                wpconfig.watch = true;
+                wpConfig.watch = true;
                 // dev mode and absolute path sourcemaps for debugging
-                wpconfig.mode = "development";
-                wpconfig.devtool = "nosources-source-map";
-                wpconfig.output.devtoolModuleFilenameTemplate = (info) => {
-                    return `${info.resourcePath}`.replace('Tools/Gulp/../../', '');
+                wpConfig.mode = "development";
+                wpConfig.devtool = "nosources-source-map";
+
+                var rootPath = path.resolve(__dirname, "../../../");
+                var absoluteSrc = path.resolve(__dirname, "../", settings.srcDirectory);
+                var prefix = isCore ? "../" : "../../";
+                wpConfig.output.devtoolModuleFilenameTemplate = (info) => {
+                    info.resourcePath = path.normalize(info.resourcePath);
+
+                    if (!path.isAbsolute(info.resourcePath)) {
+                        info.resourcePath = path.join(absoluteSrc, info.resourcePath);
+                    }
+
+                    return `${prefix}${path.relative(rootPath, info.resourcePath).replace(/\\/g, "/")}`;
                 };
 
                 var outputDirectory = config.build.tempDirectory + settings.distOutputDirectory;
-                tasks.push(webpackStream(wpconfig, webpack).pipe(gulp.dest(outputDirectory)))
+                tasks.push(webpackStream(wpConfig, webpack).pipe(gulp.dest(outputDirectory)))
 
                 tasks.push(gulp.src(settings.srcDirectory + "**/*.fx")
                     .pipe(uncommentShaders())
-                    .pipe(processShaders(config[module].isCore))
+                    .pipe(processShaders(isCore))
                 );
 
                 tasks.push(
@@ -46,7 +58,7 @@ gulp.task("watch", function startWatch() {
                         console.log(library.output + ": Shaders.");
                         gulp.src(settings.srcDirectory + "**/*.fx")
                             .pipe(uncommentShaders())
-                            .pipe(processShaders(config[module].isCore));
+                            .pipe(processShaders(isCore));
                     })
                 );
             }

+ 3 - 1
src/Debug/debugLayer.ts

@@ -174,7 +174,9 @@ declare module "scene" {
          * Hide the inspector and close its window.
          */
         public hide() {
-            this.BJSINSPECTOR.Inspector.Hide();
+            if (this.BJSINSPECTOR) {
+                this.BJSINSPECTOR.Inspector.Hide();
+            }
         }
 
         /**