Browse Source

Improve prod build. Add screenshot to readme.

Tyler Hallada 6 years ago
parent
commit
f663e23bc9
4 changed files with 26 additions and 3 deletions
  1. 4 1
      README.md
  2. BIN
      img/screenshot.png
  3. 1 0
      package.json
  4. 21 2
      webpack.config.js

+ 4 - 1
README.md

@@ -1,6 +1,9 @@
1 1
 # Transport
2 2
 
3
-A generative art project in progress.
3
+Work-in-progress procedurally generated train network simulation written in 
4
+Typescript with PixiJs.
5
+
6
+![Screenshot of simulation](img/screenshot.png)
4 7
 
5 8
 ## Development
6 9
 

BIN
img/screenshot.png


+ 1 - 0
package.json

@@ -38,6 +38,7 @@
38 38
     "tslint": "^5.9.1",
39 39
     "tslint-config-airbnb": "^5.8.0",
40 40
     "typescript": "^2.8.1",
41
+    "uglifyjs-webpack-plugin": "^1.2.4",
41 42
     "webpack": "^4.4.1",
42 43
     "webpack-cli": "^2.0.13",
43 44
     "webpack-dev-server": "^3.1.1"

+ 21 - 2
webpack.config.js

@@ -1,13 +1,20 @@
1 1
 const path = require('path');
2 2
 const ExtractTextPlugin = require('extract-text-webpack-plugin');
3 3
 const HtmlWebpackPlugin = require('html-webpack-plugin');
4
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
4 5
 
5 6
 const env = process.env.NODE_ENV;
6 7
 
8
+const prodPlugins = env === 'production' ? [
9
+  new UglifyJsPlugin({
10
+    sourceMap: true,
11
+  }),
12
+] : [];
13
+
7 14
 module.exports = {
8 15
   entry: './src/transport.ts',
9 16
   output: {
10
-    filename: 'transport.js',
17
+    filename: env === 'production' ? '[name].min.js' : '[name].js',
11 18
     path: path.resolve(__dirname, 'dist'),
12 19
   },
13 20
   mode: env === 'production' ? 'production' : 'development',
@@ -61,8 +68,20 @@ module.exports = {
61 68
       disable: env === 'development',
62 69
       filename: '[name].css',
63 70
     }),
71
+    ...prodPlugins,
64 72
   ],
65
-  devtool: 'cheap-module-eval-source-map',
73
+  optimization: {
74
+    splitChunks: {
75
+      cacheGroups: {
76
+        commons: {
77
+          test: /[\\/]node_modules[\\/]/,
78
+          name: 'vendors',
79
+          chunks: 'all',
80
+        },
81
+      },
82
+    },
83
+  },
84
+  devtool: env === 'production' ? 'source-map' : 'cheap-module-eval-source-map',
66 85
   devServer: {
67 86
     contentBase: path.join(__dirname, 'dist'),
68 87
     host: '0.0.0.0',