sebavan 7 лет назад
Родитель
Сommit
19c6909aa2

+ 60 - 0
Tools/Config/config.js

@@ -0,0 +1,60 @@
+const path = require("path");
+
+const config = require("./config.json");
+const configFolder = __dirname;
+
+const rootFolder = path.resolve(configFolder, "../../");
+const tempFolder = path.resolve(configFolder, config.build.tempDirectory);
+const outputFolder = path.resolve(configFolder, config.build.outputDirectory);
+const localDevES6 = path.join(tempFolder, config.build.localDevES6FolderName);
+const localDevUMD = path.join(tempFolder, config.build.localDevUMDFolderName);
+const ES6Package = path.join(tempFolder, config.build.ES6Package);
+
+config.computed = {
+    rootFolder,
+    tempFolder,
+    outputFolder,
+    localDevES6,
+    localDevUMD,
+    ES6Package
+}
+
+config.modules.map(function(module) {
+    const settings = config[module];
+
+    const mainDirectory = path.resolve(configFolder, settings.build.mainFolder);
+    const distFolder = (settings.build.distOutputDirectory !== undefined) ? settings.build.distOutputDirectory : module;
+    const distDirectory = path.join(outputFolder, distFolder);
+    const localDevES6Directory = path.join(localDevES6, module);
+    const localDevUMDDirectory = path.join(localDevUMD, distFolder);
+    const ES6PackageDirectory = path.join(ES6Package, module);
+
+    const webpackConfigPath = path.join(mainDirectory, "webpack.config.js");
+    const tsConfigPath = path.join(mainDirectory, "tsconfig.json");
+    const packageJSONPath = settings.build.packageJSON || path.join(distDirectory, 'package.json');
+
+    const tsConfig = require(tsConfigPath);
+    const srcDirectory = path.resolve(mainDirectory, tsConfig.compilerOptions.rootDir);
+
+    for (let library of settings.libraries) {
+        const entryPath = path.join(srcDirectory, library.entry);
+
+        library.computed = {
+            entryPath
+        };
+    }
+
+    settings.computed = {
+        mainDirectory,
+        srcDirectory,
+        distDirectory,
+        localDevES6Directory,
+        localDevUMDDirectory,
+        ES6PackageDirectory,
+        webpackConfigPath,
+        tsConfigPath,
+        packageJSONPath
+    }
+});
+
+module.exports = config;

+ 2 - 20
Tools/Gulp/config.json

@@ -4,6 +4,7 @@
         "tempDirectory": "../../.temp/",
         "localDevES6FolderName": "localDevES6",
         "localDevUMDFolderName": "localDevUMD",
+        "ES6Package": "packageES6",
         "playgroundDirectory": "../../Playground/",
         "intellisenseFile": "babylon.d.txt",
         "intellisenseSources": [
@@ -46,15 +47,13 @@
         "libraries": [
             {
                 "output": "babylon.js",
-                "maxOutput": "babylon.max.js",
                 "entry": "./Legacy/legacy.ts"
             }
         ],
         "build": {
             "mainFolder": "../../src/",
-            "srcDirectory": "../../src/",
             "loseDTSFiles": "LibDeclarations/*.d.ts",
-            "distOutputDirectory": "/",
+            "distOutputDirectory": "",
             "packageJSON": "../../package.json",
             "umd": {
                 "packageName": "babylonjs",
@@ -176,8 +175,6 @@
         ],
         "build": {
             "mainFolder": "../../materialsLibrary/",
-            "srcDirectory": "../../materialsLibrary/src/",
-            "distOutputDirectory": "/materialsLibrary/",
             "umd": {
                 "packageName": "babylonjs-materials",
                 "webpackRoot": "MATERIALS",
@@ -217,8 +214,6 @@
         ],
         "build": {
             "mainFolder": "../../postProcessLibrary/",
-            "srcDirectory": "../../postProcessLibrary/src/",
-            "distOutputDirectory": "/postProcessesLibrary/",
             "umd": {
                 "packageName": "babylonjs-post-process",
                 "webpackRoot": "POSTPROCESSES",
@@ -298,8 +293,6 @@
         ],
         "build": {
             "mainFolder": "../../proceduralTexturesLibrary/",
-            "srcDirectory": "../../proceduralTexturesLibrary/src/",
-            "distOutputDirectory": "/proceduralTexturesLibrary/",
             "umd": {
                 "packageName": "babylonjs-procedural-textures",
                 "webpackRoot": "PROCEDURALTEXTURES",
@@ -354,8 +347,6 @@
         ],
         "build": {
             "mainFolder": "../../loaders/",
-            "srcDirectory": "../../loaders/src/",
-            "distOutputDirectory": "/loaders/",
             "umd": {
                 "packageName": "babylonjs-loaders",
                 "webpackRoot": "LOADERS",
@@ -414,8 +405,6 @@
         ],
         "build": {
             "mainFolder": "../../serializers/",
-            "srcDirectory": "../../serializers/src/",
-            "distOutputDirectory": "/serializers/",
             "umd": {
                 "packageName": "babylonjs-serializers",
                 "webpackRoot": "SERIALIZERS",
@@ -466,8 +455,6 @@
         ],
         "build": {
             "mainFolder": "../../gui/",
-            "srcDirectory": "../../gui/src/",
-            "distOutputDirectory": "/gui/",
             "umd": {
                 "packageName": "babylonjs-gui",
                 "webpackRoot": "BABYLON.GUI",
@@ -494,15 +481,12 @@
         "libraries": [
             {
                 "output": "babylon.inspector.bundle.js",
-                "maxOutput": "babylon.inspector.bundle.max.js",
                 "entry": "./legacy/legacy.ts"
             }
         ],
         "build": {
             "ignoreInTestMode": true,
             "mainFolder": "../../inspector/",
-            "srcDirectory": "../../inspector/src/",
-            "distOutputDirectory": "/inspector/",
             "umd": {
                 "packageName": "babylonjs-inspector",
                 "webpackRoot": "INSPECTOR",
@@ -532,7 +516,6 @@
         ],
         "build": {
             "webpack": "../../../Viewer/webpack.gulp.config.js",
-            "srcDirectory": "../../Viewer/src/",
             "distOutputDirectory": "/viewer/",
             "dtsBundle": {
                 "name": "babylonjs-viewer",
@@ -609,7 +592,6 @@
         ],
         "build": {
             "webpack": "../../../Viewer/webpack.assets.config.js",
-            "srcDirectory": "../../Viewer/src/",
             "distOutputDirectory": "/viewer/",
             "umd": {
                 "packageName": "babylonjs-viewer-assets"

+ 20 - 9
Tools/DevLoader/BabylonLoader.js

@@ -158,21 +158,32 @@ var BABYLONDEVTOOLS;
             }
         }
 
-        Loader.prototype.loadLibrary = function(library, module) {
+        Loader.prototype.loadLibrary = function(moduleName, library, module) {
             if (library.preventLoadLibrary) {
                 return;
             }
 
+            var distFolder = (module.build.distOutputDirectory !== undefined) ?
+                module.build.distOutputDirectory :
+                "/" + moduleName;
+            distFolder += "/";
+            
             if (!useDist) {
-                var tempDirectory = '/.temp/' + localDevUMDFolderName + module.build.distOutputDirectory;
+                var tempDirectory = '/.temp/' + localDevUMDFolderName + distFolder;
                 this.loadScript(babylonJSPath + tempDirectory + library.output);
             }
-            else if (module.build.distOutputDirectory && (!testMode || !module.build.ignoreInTestMode)) {
+            else if (!testMode || !module.build.ignoreInTestMode) {
                 if (min) {
-                    this.loadScript(babylonJSPath + '/dist/preview release' + module.build.distOutputDirectory + library.output);
+                    this.loadScript(babylonJSPath + '/dist/preview release' + distFolder + library.output);
                 }
                 else {
-                    this.loadScript(babylonJSPath + '/dist/preview release' + module.build.distOutputDirectory + (library.maxOutput || library.output.replace(".min", "")));
+                    var isMinOutputName = library.output.indexOf(".min.") > -1;
+                    if (isMinOutputName) {
+                        this.loadScript(babylonJSPath + '/dist/preview release' + distFolder + library.output.replace(".min", ""));
+                    }
+                    else {
+                        this.loadScript(babylonJSPath + '/dist/preview release' + distFolder + library.output.replace(".js", ".max.js"));
+                    }
                 }
             }
         }
@@ -182,13 +193,13 @@ var BABYLONDEVTOOLS;
             this.loadESMScript(babylonJSPath + "/.temp/" + localDevES6FolderName + "/core/legacy/legacy.js");
         }
 
-        Loader.prototype.loadModule = function(module) {
+        Loader.prototype.loadModule = function(moduleName, module) {
             for (var i = 0; i < module.libraries.length; i++) {
                 if (!useDist && module.isCore) {
                     this.loadCoreDev();
                 }
                 else {
-                    this.loadLibrary(module.libraries[i], module);
+                    this.loadLibrary(moduleName, module.libraries[i], module);
                 }
             }
         }
@@ -214,7 +225,7 @@ var BABYLONDEVTOOLS;
         Loader.prototype.loadBJSScripts = function(settings) {
             // Load all the modules from the config.json.
             for (var i = 0; i < settings.modules.length; i++) {
-                this.loadModule(settings[settings.modules[i]]);
+                this.loadModule(settings.modules[i], settings[settings.modules[i]]);
             }
         }
 
@@ -223,7 +234,7 @@ var BABYLONDEVTOOLS;
             if (newCallback) {
                 callback = newCallback;
             }
-            getJson('/Tools/Gulp/config.json',
+            getJson('/Tools/Config/config.json',
                 function(data) {
                     localDevES6FolderName = data.build.localDevES6FolderName;
                     localDevUMDFolderName = data.build.localDevUMDFolderName;

+ 1 - 1
Tools/Gulp/gulpfile.js

@@ -17,7 +17,7 @@ require("./tasks/gulpTasks-tests");
 require("./tasks/gulpTasks-remapPaths");
 
 // Import Build Config
-var config = require("./config.json");
+var config = require("../Config/config.json");
 
 /**
  * Full TsLint.

+ 2 - 2
Tools/Gulp/profiling.html

@@ -31,8 +31,8 @@ On this page:
 </ol>
 	<form>
         BJS Version for Build: <select id="versions" onchange="readConfigFile()">
-            <option value="https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/Tools/Gulp/config.json">Master</option>
-            <option value="https://raw.githubusercontent.com/BabylonJS/Babylon.js/preview/Tools/Gulp/config.json">Preview</option>
+            <option value="https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/Tools/Config/config.json">Master</option>
+            <option value="https://raw.githubusercontent.com/BabylonJS/Babylon.js/preview/Tools/Config/config.json">Preview</option>
             <option value="./config.json">Current Local Branch (Firefox only)</option>
         </select><br>
 

+ 1 - 1
Tools/Gulp/tasks/gulpTasks-intellisense.js

@@ -4,7 +4,7 @@ var concat = require("gulp-concat");
 var replace = require("gulp-replace");
 
 // Read the full config.
-var config = require("../config.json");
+var config = require("../../Config/config.json");
 
 /**
  * Process the .d.ts files or Playground intellisense.

+ 15 - 29
Tools/Gulp/tasks/gulpTasks-libraries.js

@@ -14,26 +14,25 @@ var processModuleDeclarationToNamespace = require('../helpers/gulp-processModule
 var del = require("del");
 
 // Import Build Config
-var configPath = "../config.json";
-var config = require(configPath);
+var config = require("../../Config/config.js");
 
 // Constants
-const tempTypingsFile = "tempTypings.js";
-const tempTypingsFolder = "../../.temp/";
-const tempTypingsPath = tempTypingsFolder + tempTypingsFile.replace(".js", ".d.ts");
+const tempTypingsFileName = "tempTypings.js";
+const tempTypingsFile = path.join(config.computed.tempFolder, tempTypingsFileName);
+const tempTypingsPath = path.join(config.computed.tempFolder, tempTypingsFileName.replace(".js", ".d.ts"));
 
 /**
  * Clean shader ts files.
  */
 var cleanShaders = function(settings) {
-    return del([settings.build.srcDirectory + "**/*.fx.ts"]);
+    return del([settings.computed.srcDirectory + "**/*.fx.ts"]);
 }
 
 /**
  * Create shader ts files.
  */
 var buildShaders = function(settings) {
-    return gulp.src(settings.build.srcDirectory + "**/*.fx")
+    return gulp.src(settings.computed.srcDirectory + "**/*.fx")
             .pipe(uncommentShaders())
             .pipe(processShaders(settings.isCore));
 }
@@ -43,21 +42,19 @@ var buildShaders = function(settings) {
  */
 var buildExternalLibrariesMultiEntry = function(libraries, settings, isMin) {
     // Convert Module to Namespace for globals
-    var outputDirectory = config.build.outputDirectory + settings.build.distOutputDirectory;
+    var outputDirectory = settings.computed.distDirectory;
 
     // Does name contain .min. for min files.
     var isMinOutputName = libraries[0].output.indexOf(".min.") > -1;
 
     // Webpack Config.
-    var configFolder = path.dirname(path.resolve(__dirname, configPath));
-    var wpConfigPath = path.join(settings.build.mainFolder, "webpack.config.js");
-    var wpConfig = require(path.resolve(configFolder, wpConfigPath));
+    var wpConfig = require(settings.computed.webpackConfigPath);
 
     // 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);
+        wpConfig.entry[name] = library.computed.entryPath;
     }
 
     // Create output by type (min vs max).
@@ -68,16 +65,14 @@ var buildExternalLibrariesMultiEntry = function(libraries, settings, isMin) {
     else {
         // Map Output
         wpConfig.devtool = "source-map";
-        var rootPath = path.resolve(__dirname, "../../../");
-        var absoluteSrc = path.resolve(__dirname, "../", settings.build.srcDirectory);
         wpConfig.output.devtoolModuleFilenameTemplate = (info) => {
             info.resourcePath = path.normalize(info.resourcePath);
 
             if (!path.isAbsolute(info.resourcePath)) {
-                info.resourcePath = path.join(absoluteSrc, info.resourcePath);
+                info.resourcePath = path.join(settings.computed.srcDirectory, info.resourcePath);
             }
 
-            return `webpack://BABYLONJS/${path.relative(rootPath, info.resourcePath).replace(/\\/g, "/")}`;
+            return `webpack://BABYLONJS/${path.relative(config.computed.rootFolder, info.resourcePath).replace(/\\/g, "/")}`;
         };
 
         // Generate unminified file.
@@ -97,18 +92,9 @@ var buildAMDDTSFiles = function(libraries, settings, cb) {
     // TODO. Generate all d.ts
     let library = libraries[0];
     if (!library.preventLoadLibrary) {
-        // Create temp directory.
-        let srcDirectory = settings.build.srcDirectory;
-        let depthCount = srcDirectory.match(/\//g).length - srcDirectory.match(/\.\.\//g).length;
-        let tempDirectory = "";
-        for (let i = 0; i < depthCount; i++) {
-            tempDirectory += "../"
-        }
-        tempDirectory += ".temp/";
-
         // Generate DTS the old way...
-        cp.execSync('tsc --module amd --outFile "' + tempDirectory + tempTypingsFile + '" --emitDeclarationOnly true', {
-            cwd: settings.build.srcDirectory
+        cp.execSync(`tsc --module amd --outFile "${tempTypingsFile}" --emitDeclarationOnly true`, {
+            cwd: settings.computed.srcDirectory
         });
     }
     cb();
@@ -119,7 +105,7 @@ var buildAMDDTSFiles = function(libraries, settings, cb) {
  */
 var appendLoseDTSFiles = function(settings) {
     if (settings.build.loseDTSFiles) {
-        return gulp.src([tempTypingsPath, path.join(settings.build.srcDirectory, settings.build.loseDTSFiles)], { base: "./"})
+        return gulp.src([tempTypingsPath, path.join(settings.computed.srcDirectory, settings.build.loseDTSFiles)], { base: "./"})
             .pipe(concat(tempTypingsPath))
             .pipe(gulp.dest(tempTypingsPath));
     }
@@ -131,7 +117,7 @@ var appendLoseDTSFiles = function(settings) {
  */
 var processDTSFiles = function(libraries, settings, cb) {
     // Convert Module to Namespace for globals
-    var outputDirectory = config.build.outputDirectory + settings.build.distOutputDirectory;
+    var outputDirectory = settings.computed.distDirectory;
 
     // TODO. Generate all d.ts
     let library = libraries[0];

+ 4 - 3
Tools/Gulp/tasks/gulpTasks-localRun.js

@@ -6,7 +6,7 @@ var fs = require('fs');
 var path = require('path');
 
 // Read the full config.
-var config = require("../config.json");
+var config = require("../../Config/config.json");
 
 // Comand line parsing.
 var commandLineOptions = minimist(process.argv.slice(2), {
@@ -20,8 +20,9 @@ var skipExtensions = [".js", ".glb", ".gltf", ".bin", ".html", ".gif", ".jpg", "
  * Embedded webserver for test convenience.
  */
 gulp.task("webserver", function() {
+    var rootRelativePath = "../../";
     var options = {
-        root: "../../.",
+        root: rootRelativePath,
         port: 1338,
         livereload: false,
         middleware: function(connect, opt) {
@@ -29,7 +30,7 @@ gulp.task("webserver", function() {
                 var extension = path.extname(decodeURIComponent(req.originalUrl));
                 if (req.originalUrl.indexOf(config.build.localDevES6FolderName) > -1 && skipExtensions.indexOf(extension) === -1) {
                     // Append .js for es6 modules.
-                    if (!fs.existsSync("../../" + req.originalUrl)) {
+                    if (!fs.existsSync(rootRelativePath + req.originalUrl)) {
                         req.url += ".js";
                     }
                 }

+ 1 - 1
Tools/Gulp/tasks/gulpTasks-tests.js

@@ -11,7 +11,7 @@ var rename = require("gulp-rename");
 var rmDir = require("../../NodeHelpers/rmDir");
 
 // Read the full config.
-var config = require("../config.json");
+var config = require("../../Config/config.json");
 var relativeRootDir = "../../../";
 var rootDir = __dirname + "/" + relativeRootDir;
 

+ 4 - 9
Tools/Gulp/tasks/gulpTasks-tsLint.js

@@ -18,14 +18,14 @@ var tsLintConfig = {
 }
 
 // Read the full config.
-var config = require("../config.json");
+var config = require("../../Config/config.js");
 
 /*
  * TsLint all typescript files from the src directory.
  */
-var tsLintExternalLibrary = function(library, settings, watch) {
+var tsLintExternalLibrary = function(settings) {
     const fxFilter = filter(['**', '!**/*.fragment.ts', '!**/*.vertex.ts', '!**/ShadersInclude/**'], { restore: false });
-    return gulp.src((settings.build.srcDirectory) + "/**/*.ts")
+    return gulp.src((settings.computed.srcDirectory) + "/**/*.ts")
         .pipe(fxFilter)
         .pipe(gulpTslint(tsLintConfig))
         .pipe(gulpTslint.report());
@@ -39,12 +39,7 @@ config.modules.map(function(module) {
     gulp.task(module + "-tsLint", function() {
         var settings = config[module];
 
-        var tasks = settings.libraries.map(function(library) {
-            return tsLintExternalLibrary(library, settings, false);
-        });
-    
-        let mergedTasks = merge2(tasks);
-        return mergedTasks;
+        return tsLintExternalLibrary(settings, false);
     });
 });
 

+ 1 - 1
Tools/Gulp/tasks/gulpTasks-typedoc.js

@@ -6,7 +6,7 @@ var typedoc = require("gulp-typedoc");
 var validateTypedoc = require("../helpers/gulp-validateTypedoc");
 
 // Read the full config.
-var config = require("../config.json");
+var config = require("../../Config/config.json");
 
 /**
  * Generate the TypeDoc JSON output in order to create code metadata.

+ 1 - 1
Tools/Gulp/tasks/gulpTasks-viewerLibraries.js

@@ -12,7 +12,7 @@ var processDeclaration = require('../helpers/gulp-processModuleDeclarationToName
 var addModuleExports = require("../helpers/gulp-addModuleExports");
 
 // Import Build Config
-var config = require("../config.json");
+var config = require("../../Config/config.json");
 
 /**
  * Build the viewer

+ 9 - 9
Tools/Gulp/tasks/gulpTasks-watchCore.js

@@ -9,7 +9,7 @@ var uncommentShaders = require('../helpers/gulp-removeShaderComments');
 var rmDir = require("../../NodeHelpers/rmDir");
 
 // Read the full config.
-var config = require("../config.json");
+var config = require("../../Config/config.js");
 
 // Constants
 var module = "core";
@@ -18,7 +18,7 @@ var module = "core";
  * Process shader ts files.
  */
 gulp.task("watchCore-cleanShaders", async function startWatch() {
-    var settings = config[module].build;
+    var settings = config[module].computed;
 
     // Clean shaders.
     await del([settings.srcDirectory + "**/*.fx.ts"]);
@@ -32,12 +32,12 @@ gulp.task("watchCore-cleanShaders", async function startWatch() {
 /**
  * Watch ts files and fire repective tasks.
  */
-gulp.task("watchCore", gulp.series("watchCore-cleanShaders"), async function startWatch() {
-    var settings = config[module].build;
+gulp.task("watchCore", gulp.series("watchCore-cleanShaders", async function() {
+    var settings = config[module].computed;
     var library = config[module].libraries[0];
 
-    // Generat output path.
-    var outputDirectory = "../.temp/" + config.build.localDevES6FolderName + "/" + module;
+    // Generate output path.
+    var outputDirectory = settings.localDevES6Directory;
 
     // Clean Folder.
     rmDir(outputDirectory);
@@ -48,7 +48,7 @@ gulp.task("watchCore", gulp.series("watchCore-cleanShaders"), async function sta
         async: true,
         verbose: true
     };
-    shelljs.exec(`tsc --isolatedModules true --declaration false --target es5 --module es2015 --outDir ${outputDirectory} -w`, options, function(code, stdout, stderr) {
+    shelljs.exec(`tsc --importHelpers false --isolatedModules true --declaration false --target es5 --module es2015 --outDir "${outputDirectory}" -w`, options, function(code, stdout, stderr) {
         if (stderr) {
             console.log(stderr);
         }
@@ -57,11 +57,11 @@ gulp.task("watchCore", gulp.series("watchCore-cleanShaders"), async function sta
         }
     });
 
-    // Launch shader watch    
+    // Launch shader watch.
     gulp.watch(settings.srcDirectory + "**/*.fx", { interval: 1000 }, function() {
         console.log(library.output + ": Shaders.");
         return gulp.src(settings.srcDirectory + "**/*.fx")
             .pipe(uncommentShaders())
             .pipe(processShaders(true));
     });
-});
+}));

+ 9 - 12
Tools/Gulp/tasks/gulpTasks-watchLibraries.js

@@ -7,8 +7,7 @@ var processShaders = require("../helpers/gulp-processShaders");
 var uncommentShaders = require('../helpers/gulp-removeShaderComments');
 
 // Read the full config.
-var configPath = "../config.json";
-var config = require(configPath);
+var config = require("../../Config/config.js");
 
 /**
  * Watch ts files and fire repective tasks.
@@ -17,7 +16,7 @@ gulp.task("watchLibraries", function startWatch() {
     var tasks = [];
 
     config.modules.map(function(module) {
-        var settings = config[module].build;
+        var settings = config[module].computed;
         if (!config[module].isCore && settings) {
             for (var index = 0; index < config[module].libraries.length; index++) {
                 var library = config[module].libraries[index];
@@ -25,9 +24,7 @@ gulp.task("watchLibraries", function startWatch() {
                     continue;
                 }
 
-                var configFolder = path.dirname(path.resolve(__dirname, configPath));
-                var wpConfigPath = path.join(settings.build.mainFolder, "webpack.config.js");
-                var wpConfig = require(path.resolve(configFolder, wpConfigPath));
+                var wpConfig = require(settings.webpackConfigPath);
 
                 // watch on.
                 wpConfig.watch = true;
@@ -35,16 +32,15 @@ gulp.task("watchLibraries", function startWatch() {
                 wpConfig.mode = "development";
                 wpConfig.devtool = "nosources-source-map";
 
-                var rootPath = path.resolve(__dirname, "../../../");
-                var absoluteSrc = path.resolve(__dirname, "../", settings.srcDirectory);
+                // Source Map Remapping for dev tools.
                 wpConfig.output.devtoolModuleFilenameTemplate = (info) => {
                     info.resourcePath = path.normalize(info.resourcePath);
 
                     if (!path.isAbsolute(info.resourcePath)) {
-                        info.resourcePath = path.join(absoluteSrc, info.resourcePath);
+                        info.resourcePath = path.join(settings.srcDirectory, info.resourcePath);
                     }
 
-                    return `../../../${path.relative(rootPath, info.resourcePath).replace(/\\/g, "/")}`;
+                    return `../../../${path.relative(config.computed.rootFolder, info.resourcePath).replace(/\\/g, "/")}`;
                 };
 
                 tasks.push(
@@ -53,9 +49,10 @@ gulp.task("watchLibraries", function startWatch() {
                         .pipe(processShaders(false))
                 );
 
-                var outputDirectory = config.build.tempDirectory + config.build.localDevUMDFolderName + settings.distOutputDirectory;
+                var outputDirectory = settings.localDevUMDDirectory;
                 tasks.push(
-                    webpackStream(wpConfig, webpack).pipe(gulp.dest(outputDirectory))
+                    webpackStream(wpConfig, webpack)
+                        .pipe(gulp.dest(outputDirectory))
                 );
 
                 tasks.push(

+ 13 - 15
Tools/Publisher/publisher.js

@@ -10,16 +10,14 @@ const colorConsole = require("../NodeHelpers/colorConsole");
 let doNotBuild = false;
 let doNotPublish = false;
 
-// Pathe management.
+// Path management.
 process.env.PATH += (path.delimiter + path.join(__dirname, 'node_modules', '.bin'));
 
 // Global Variables.
-const config = require("../gulp/config.json");
+const config = require("../Config/config.js");
 const modules = config.modules.concat(config.viewerModules);
 const basePath = config.build.outputDirectory;
-const tempPath = config.build.tempDirectory + "packageES6/";
-const coreSrc = config.core.build.srcDirectory;
-const enginePath = coreSrc + "Engines/engine.ts";
+const enginePath = path.join(config.core.computed.srcDirectory, "Engines/engine.ts");
 
 /**
  * Get Files from folder.
@@ -72,8 +70,8 @@ function getEngineVersion() {
 /**
  * Publish a package to npm.
  */
-function publish(version, packageName, basePath, public) {
-    colorConsole.log('    Publishing ' + packageName.blue.bold + " from " + basePath.cyan);
+function publish(version, packageName, publishPath, public) {
+    colorConsole.log('    Publishing ' + packageName.blue.bold + " from " + publishPath.cyan);
 
     let tag = "";
     // check for alpha or beta
@@ -82,7 +80,7 @@ function publish(version, packageName, basePath, public) {
     }
 
     //publish the respected package
-    var cmd = 'npm publish \"' + basePath + "\"" + tag;
+    var cmd = 'npm publish "' + publishPath + '"' + tag;
     if (public) {
        cmd += " --access public";
     }
@@ -123,14 +121,14 @@ function processEs6Packages(version) {
 
         colorConsole.log("Process " + "ES6".magenta + " Package: " + moduleName.blue.bold);
 
-        let projectPath = module.build.mainFolder;
-        let buildPath = path.normalize(tempPath + moduleName);
-        let legacyPackageJson = require(module.build.packageJSON || basePath + module.build.distOutputDirectory + 'package.json');
+        let projectPath = module.computed.mainDirectory;
+        let buildPath = module.computed.ES6PackageDirectory;
+        let legacyPackageJson = require(module.computed.packageJSONPath);
 
         colorConsole.log("    Cleanup " + buildPath.cyan);
         rmDir(buildPath);
 
-        let command = 'tsc --inlineSources -t es5 -m esNext -p ' + projectPath + ' --outDir ' + buildPath;
+        let command = 'tsc --inlineSources -t es5 -m esNext -p "' + projectPath + '" --outDir "' + buildPath + '"';
         colorConsole.log("    Executing " + command.yellow);
 
         let tscCompile = shelljs.exec(command);
@@ -209,7 +207,7 @@ function processLegacyPackages(version) {
             processLegacyViewer(module, version);
         }
         else {
-            let outputDirectory = module.build.legacyPackageOutputDirectory || basePath + module.build.distOutputDirectory;
+            let outputDirectory = module.build.legacyPackageOutputDirectory || module.computed.distDirectory;
 
             if (module.build.requiredFiles) {
                 module.build.requiredFiles.forEach(file => {
@@ -218,7 +216,7 @@ function processLegacyPackages(version) {
                 });
             }
 
-            let packageJson = require(outputDirectory + 'package.json');
+            let packageJson = require(outputDirectory + '/package.json');
             packageJson.version = version;
             colorConsole.log("    Update package version to: " + version.green);
 
@@ -229,7 +227,7 @@ function processLegacyPackages(version) {
                     }
                 });
             }
-            fs.writeFileSync(outputDirectory + 'package.json', JSON.stringify(packageJson, null, 4));
+            fs.writeFileSync(outputDirectory + '/package.json', JSON.stringify(packageJson, null, 4));
 
             publish(version, moduleName, outputDirectory);
 

+ 5 - 12
Tools/WebpackPlugins/babylonWebpackConfig.js

@@ -1,11 +1,8 @@
-const path = require('path');
 const webpack = require('webpack');
 const babylonExternals = require('./babylonExternals');
 const hardSourceWebpackPlugin = require('hard-source-webpack-plugin');
 
-var configPath = "../Gulp/config.json";
-const configFolder = path.dirname(path.resolve(__dirname, configPath));
-const config = require(configPath);
+const config = require("../Config/config.js");
 
 module.exports = function defaultConfig(options) {
     if (!options) {
@@ -15,21 +12,17 @@ module.exports = function defaultConfig(options) {
     const module = options.module;
     const settings = config[module];
 
-    const src = path.resolve(__dirname, settings.build.srcDirectory);
-    const wpConfigPath = path.join(settings.build.mainFolder, "webpack.config.js");
-    const webpackFolder = path.dirname(path.resolve(configFolder, wpConfigPath));
-
     options.resolveExtensions = options.resolveExtensions || [];
     options.moduleRules = options.moduleRules || [];
     options.plugins = options.plugins || [];
 
     return {
-        context: src,
+        context: settings.computed.srcDirectory,
         entry: {
-            [settings.build.umd.packageName]: path.resolve(src, settings.libraries[0].entry),
+            [settings.build.umd.packageName]: settings.libraries[0].computed.entryPath,
         },
         output: {
-            path: path.resolve(__dirname, config.build.outputDirectory) + settings.build.distOutputDirectory,
+            path: settings.computed.distDirectory,
             filename: settings.libraries[0].output,
             libraryTarget: 'umd',
             library: {
@@ -49,7 +42,7 @@ module.exports = function defaultConfig(options) {
                 test: /\.tsx?$/,
                 loader: 'awesome-typescript-loader',
                 options: {
-                    configFileName: path.resolve(webpackFolder, './tsconfig.json'),
+                    configFileName: settings.computed.tsConfigPath,
                     declaration: false
                 }
             }, ...options.moduleRules]

+ 10 - 10
loaders/tsconfig.json

@@ -1,15 +1,15 @@
 {
   "extends": "../tsconfigRules",
   "compilerOptions": {
-      "baseUrl": "./src/",
-      "rootDir": "./src/",
-      "paths": {
-          "babylonjs": [
-            "../../dist/preview release/babylon.module.d.ts",
-          ],
-          "babylonjs-gltf2interface": [
-            "../../dist/preview release/glTF2Interface/babylon.glTF2Interface.d.ts"
-          ],
-      }
+    "baseUrl": "./src/",
+    "rootDir": "./src/",
+    "paths": {
+        "babylonjs": [
+          "../../dist/preview release/babylon.module.d.ts"
+        ],
+        "babylonjs-gltf2interface": [
+          "../../dist/preview release/glTF2Interface/babylon.glTF2Interface.d.ts"
+        ]
+    }
   }
 }

+ 1 - 1
materialsLibrary/readme.md

@@ -39,7 +39,7 @@ To build all materials and generate the *dist* folder, just run from the tools/g
 gulp materialsLibrary
 ```
 
-To integrate your new material to the build process, you have to edit the config.json file in the tools/gulp and add an entry in the "materialsLibrary/libraries" section of the file:
+To integrate your new material to the build process, you have to edit the config.json file in the tools/config and add an entry in the "materialsLibrary/libraries" section of the file:
 
 ```
   "libraries": [

+ 1 - 1
postProcessLibrary/readme.md

@@ -21,7 +21,7 @@ To build all post processes and generate the *dist* folder, just run from the to
 gulp postProcesLibrary
 ```
 
-To integrate your new post process to the build process, you have to edit the config.json file in the tools/gulp folder and add an entry in the "postProcessLibray/libraries" section of the file:
+To integrate your new post process to the build process, you have to edit the config.json file in the tools/config folder and add an entry in the "postProcessLibray/libraries" section of the file:
 
 ```
   "libraries": [   

+ 10 - 10
serializers/tsconfig.json

@@ -1,15 +1,15 @@
 {
   "extends": "../tsconfigRules",
   "compilerOptions": {
-      "baseUrl": "./src/",
-      "rootDir": "./src/",
-      "paths": {
-          "babylonjs": [
-            "../../dist/preview release/babylon.module.d.ts",
-          ],
-          "babylonjs-gltf2interface": [
-            "../../dist/preview release/glTF2Interface/babylon.glTF2Interface.d.ts"
-          ],
-      }
+    "baseUrl": "./src/",
+    "rootDir": "./src/",
+    "paths": {
+      "babylonjs": [
+        "../../dist/preview release/babylon.module.d.ts"
+      ],
+      "babylonjs-gltf2interface": [
+        "../../dist/preview release/glTF2Interface/babylon.glTF2Interface.d.ts"
+      ]
+    }
   }
 }

+ 1 - 1
tests/unit/karma.conf.js

@@ -31,7 +31,7 @@ module.exports = function (config) {
             { pattern: 'Playground/scenes/**/*', watched: false, included: false, served: true },
             { pattern: 'Playground/textures/**/*', watched: false, included: false, served: true },
             { pattern: 'Playground/sounds/**/*', watched: false, included: false, served: true },
-            { pattern: 'Tools/Gulp/config.json', watched: false, included: false, served: true },
+            { pattern: 'Tools/Config/config.json', watched: false, included: false, served: true },
         ],
         proxies: {
             '/': '/base/'

+ 1 - 1
tests/validation/karma.conf.browserstack.js

@@ -25,7 +25,7 @@ module.exports = function (config) {
             { pattern: 'Playground/scenes/**/*', watched: false, included: false, served: true },
             { pattern: 'Playground/textures/**/*', watched: false, included: false, served: true },
             { pattern: 'Playground/sounds/**/*', watched: false, included: false, served: true },
-            { pattern: 'Tools/Gulp/config.json', watched: false, included: false, served: true },
+            { pattern: 'Tools/Config/config.json', watched: false, included: false, served: true },
         ],
         proxies: {
             '/': '/base/'

+ 1 - 1
tests/validation/karma.conf.js

@@ -27,7 +27,7 @@ module.exports = function (config) {
             { pattern: 'Playground/scenes/**/*', watched: false, included: false, served: true },
             { pattern: 'Playground/textures/**/*', watched: false, included: false, served: true },
             { pattern: 'Playground/sounds/**/*', watched: false, included: false, served: true },
-            { pattern: 'Tools/Gulp/config.json', watched: false, included: false, served: true },
+            { pattern: 'Tools/Config/config.json', watched: false, included: false, served: true },
         ],
         proxies: {
             '/': '/base/'