浏览代码

Added launch settings in VSCode
The webpack server should still be started (had a problem with task definition). To start the watch server:

npm run start:server

This will build the JS file and will watch for changes.

Raanan Weber 7 年之前
父节点
当前提交
31b9f20410
共有 3 个文件被更改,包括 51 次插入22 次删除
  1. 26 13
      .vscode/launch.json
  2. 4 2
      Viewer/package.json
  3. 21 7
      Viewer/webpack.config.js

+ 26 - 13
.vscode/launch.json

@@ -11,22 +11,22 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
             ]
-        },         
+        },
         {
             "name": "Launch playground (Chrome)",
             "type": "chrome",
             "request": "launch",
             "url": "http://localhost:1338/Playground/index-local.html",
             "webRoot": "${workspaceRoot}/",
-            "sourceMaps": true,            
+            "sourceMaps": true,
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
             ]
-        },        
+        },
         {
             "name": "Launch playground (Chrome+WebGL 1.0 forced)",
             "type": "chrome",
@@ -37,7 +37,7 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--disable-es3-apis" 
+                "--disable-es3-apis"
             ]
         },
         {
@@ -50,7 +50,7 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
             ]
         },
         {
@@ -63,7 +63,7 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
             ]
         },
         {
@@ -76,7 +76,7 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
             ]
         },
         {
@@ -89,7 +89,7 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
             ]
         },
         {
@@ -102,9 +102,9 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
             ]
-        },      
+        },
         {
             "name": "Launch Build Validation (Chrome)",
             "type": "chrome",
@@ -115,7 +115,20 @@
             "preLaunchTask": "run",
             "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
             "runtimeArgs": [
-                "--enable-unsafe-es3-apis" 
+                "--enable-unsafe-es3-apis"
+            ]
+        },
+        {
+            "name": "Launch Viewer (Chrome)",
+            "type": "chrome",
+            "request": "launch",
+            "url": "http://localhost:9000/",
+            "webRoot": "${workspaceRoot}/Viewer/dist/",
+            "sourceMaps": true,
+            //"preLaunchTask": "build-viewer", // TODO - test why this fails.
+            "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
+            "runtimeArgs": [
+                "--enable-unsafe-es3-apis"
             ]
         }
     ]

+ 4 - 2
Viewer/package.json

@@ -3,6 +3,7 @@
     "version": "0.1.0",
     "description": "A viewer using BabylonJS to display 3D elements natively",
     "scripts": {
+        "start:server": "webpack-dev-server",
         "test": "echo \"Error: no test specified\" && exit 1"
     },
     "repository": {
@@ -27,8 +28,9 @@
         "json-loader": "^0.5.7",
         "ts-loader": "^2.3.7",
         "typescript": "^2.5.3",
-        "uglifyjs-webpack-plugin": "^0.4.6",
-        "webpack": "^3.6.0"
+        "uglifyjs-webpack-plugin": "^1.0.0-beta.3",
+        "webpack": "^3.6.0",
+        "webpack-dev-server": "^2.9.2"
     },
     "dependencies": {
         "babylonjs": "^3.1.0-alpha3.5",

+ 21 - 7
Viewer/webpack.config.js

@@ -5,14 +5,15 @@ const webpack = require('webpack');
 module.exports = {
     entry: {
         'viewer': './src/index.ts',
-        'viewer.min': './src/index.ts',
+        //'viewer.min': './src/index.ts',
     },
     output: {
         path: path.resolve(__dirname, 'dist'),
         filename: '[name].js',
         libraryTarget: 'umd',
         library: 'Viewer3D',
-        umdNamedDefine: true
+        umdNamedDefine: true,
+        devtoolModuleFilenameTemplate: '[absolute-resource-path]'
     },
     resolve: {
         extensions: ['.ts', '.tsx', '.js']
@@ -22,12 +23,19 @@ module.exports = {
         new webpack.WatchIgnorePlugin([
             /\.d\.ts$/
         ]),
-        new UglifyJSPlugin({
-            minimize: true,
-            comments: false,
+        /*new UglifyJSPlugin({
+
+            uglifyOptions: {
+                compress: {
+                    warnings: false,
+                },
+                output: {
+                    comments: false
+                }
+            },
             sourceMap: true,
-            include: /\.min\.js$/,
-        })
+            include: /\.min/,
+        })*/
     ],
     module: {
         loaders: [{
@@ -45,5 +53,11 @@ module.exports = {
             test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
             use: 'base64-image-loader?limit=1000&name=[name].[ext]'
         }]
+    },
+    devServer: {
+        contentBase: path.join(__dirname, "dist"),
+        compress: true,
+        //open: true,
+        port: 9000
     }
 }