Bladeren bron

build improvements

Alexander Rose 6 jaren geleden
bovenliggende
commit
a52060d65e
3 gewijzigde bestanden met toevoegingen van 27 en 25 verwijderingen
  1. 7 11
      package.json
  2. 2 2
      tsconfig.json
  3. 18 12
      webpack.config.js

+ 7 - 11
package.json

@@ -12,20 +12,16 @@
   },
   "scripts": {
     "lint": "tslint src/**/*.ts",
-    "build": "cpx \"src/**/*.{vert,frag,glsl,scss,woff,woff2,ttf,otf,eot,svg,html,gql}\" build/node_modules/ && tsc",
+    "test": "jest",
+    "build": "cpx \"src/**/*.{vert,frag,glsl,scss,woff,woff2,ttf,otf,eot,svg,html,gql}\" build/src/ && tsc -b",
+    "postinstall": "npm run build",
     "watch": "concurrently --kill-others \"npm:watch-ts\" \"npm:watch-extra\" \"npm:watch-webpack\"",
     "watch-ts": "tsc -watch",
-    "watch-extra": "cpx \"src/**/*.{vert,frag,glsl,scss,woff,woff2,ttf,otf,eot,svg,html,gql}\" build/node_modules/ --watch",
-    "watch-all-win": "start cmd /K npm run watch-ts & start cmd /K npm run watch-extra & start cmd /K npm run watch-viewer & start http-server -p 1338",
-    "test": "jest",
+    "watch-extra": "cpx \"src/**/*.{vert,frag,glsl,scss,woff,woff2,ttf,otf,eot,svg,html,gql}\" build/src/ --watch",
     "build-webpack": "webpack --mode development",
     "watch-webpack": "webpack -w --mode development",
-    "build-viewer": "webpack build/node_modules/apps/viewer/index.js --mode development -o build/viewer/index.js",
-    "watch-viewer": "webpack build/node_modules/apps/viewer/index.js -w --mode development -o build/viewer/index.js",
-    "build-ms-query": "webpack build/node_modules/apps/model-server-query/index.js --mode development -o build/model-server-query/index.js",
-    "watch-ms-query": "webpack build/node_modules/apps/model-server-query/index.js -w --mode development -o build/model-server-query/index.js",
-    "model-server": "node build/node_modules/servers/model/server.js",
-    "model-server-watch": "nodemon --watch build/node_modules build/node_modules/servers/model/server.js"
+    "model-server": "node build/src/servers/model/server.js",
+    "model-server-watch": "nodemon --watch build/src build/src/servers/model/server.js"
   },
   "nodemonConfig": {
     "ignoreRoot": [
@@ -46,7 +42,7 @@
     },
     "moduleDirectories": [
       "node_modules",
-      "build/node_modules"
+      "build/src"
     ],
     "testURL": "http://localhost/",
     "moduleNameMapper": {

+ 2 - 2
tsconfig.json

@@ -12,7 +12,7 @@
         // "downlevelIteration": true,
         "jsx": "react",
         "lib": [ "es6", "dom", "esnext.asynciterable", "es2016" ],
-        "outDir": "build/node_modules",
+        "outDir": "build",
         "baseUrl": "src",
         "paths": {
             "mol-app": ["./mol-app"],
@@ -34,5 +34,5 @@
             "mol-canvas3d": ["./mol-view"]
         }
     },
-    "include": [ "**/*" ],
+    "include": [ "src/**/*" ],
 }

+ 18 - 12
webpack.config.js

@@ -9,18 +9,18 @@ const sharedConfig = {
             {
                 loader: 'raw-loader',
                 test: /\.(glsl|frag|vert)$/,
-                include: [ path.resolve(__dirname, 'build/node_modules/') ],
+                include: [ path.resolve(__dirname, 'build/src/') ],
             },
             {
                 loader: 'glslify-loader',
                 test: /\.(glsl|frag|vert)$/,
-                include: [ path.resolve(__dirname, 'build/node_modules/') ]
+                include: [ path.resolve(__dirname, 'build/src/') ]
             },
 
             {
                 loader: 'file-loader',
                 test: /\.(woff2?|ttf|otf|eot|svg|html)$/,
-                include: [ path.resolve(__dirname, 'build/node_modules/') ],
+                include: [ path.resolve(__dirname, 'build/src/') ],
                 options: {
                     name: '[name].[ext]'
                 }
@@ -33,26 +33,32 @@ const sharedConfig = {
     },
     plugins: [
         // new CircularDependencyPlugin({
-        //     include: [ path.resolve(__dirname, 'build/node_modules/') ],
+        //     include: [ path.resolve(__dirname, 'build/src/') ],
         //     failOnError: false,
         //     cwd: process.cwd(),
         // }),
         new ExtraWatchWebpackPlugin({
             files: [
-                './build/node_modules/**/*.vert',
-                './build/node_modules/**/*.frag',
-                './build/node_modules/**/*.glsl',
-                './build/node_modules/**/*.scss',
-                './build/node_modules/**/*.html'
+                './build/src/**/*.vert',
+                './build/src/**/*.frag',
+                './build/src/**/*.glsl',
+                './build/src/**/*.scss',
+                './build/src/**/*.html'
             ],
         }),
-        new MiniCssExtractPlugin({ filename: "app.css" })
-    ]
+        new MiniCssExtractPlugin({ filename: 'app.css' })
+    ],
+    resolve: {
+        modules: [
+            'node_modules',
+            path.resolve(__dirname, 'build/src/')
+        ],
+    }
 }
 
 function createEntryPoint(name, dir, out) {
     return {
-        entry: path.resolve(__dirname, `build/node_modules/${dir}/${name}.js`),
+        entry: path.resolve(__dirname, `build/src/${dir}/${name}.js`),
         output: { filename: `${name}.js`, path: path.resolve(__dirname, `build/${out}`) },
         ...sharedConfig
     }