Procedurally generated train network simulation http://transport.hallada.net

webpack.config.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. const path = require('path');
  2. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  3. const HtmlWebpackPlugin = require('html-webpack-plugin');
  4. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  5. const env = process.env.NODE_ENV;
  6. const prodPlugins = env === 'production' ? [
  7. new UglifyJsPlugin({
  8. sourceMap: true,
  9. }),
  10. ] : [];
  11. module.exports = {
  12. entry: './src/transport.ts',
  13. output: {
  14. filename: env === 'production' ? '[name].min.js' : '[name].js',
  15. path: path.resolve(__dirname, 'dist'),
  16. },
  17. mode: env === 'production' ? 'production' : 'development',
  18. module: {
  19. rules: [
  20. {
  21. test: /\.js$/,
  22. exclude: /node_modules/,
  23. use: {
  24. loader: 'babel-loader',
  25. options: {
  26. presets: [
  27. '@babel/preset-env',
  28. ],
  29. plugins: [
  30. '@babel/proposal-class-properties',
  31. '@babel/proposal-object-rest-spread',
  32. ],
  33. cacheDirectory: env === 'development',
  34. },
  35. },
  36. },
  37. {
  38. test: /\.tsx?$/,
  39. use: 'ts-loader',
  40. exclude: /node_modules/,
  41. },
  42. {
  43. test: /\.css$/,
  44. use: env === 'production'
  45. ? ExtractTextPlugin.extract({
  46. fallback: 'style-loader',
  47. use: ['css-loader'],
  48. })
  49. : ['style-loader', 'css-loader'],
  50. },
  51. {
  52. test: /\.png$/,
  53. use: 'file-loader',
  54. },
  55. ],
  56. },
  57. resolve: {
  58. extensions: ['.tsx', '.ts', '.js'],
  59. },
  60. plugins: [
  61. new HtmlWebpackPlugin({
  62. template: path.join(__dirname, 'index.html'),
  63. }),
  64. new ExtractTextPlugin({
  65. disable: env === 'development',
  66. filename: '[name].css',
  67. }),
  68. ...prodPlugins,
  69. ],
  70. optimization: {
  71. splitChunks: {
  72. cacheGroups: {
  73. commons: {
  74. test: /[\\/]node_modules[\\/]/,
  75. name: 'vendors',
  76. chunks: 'all',
  77. },
  78. },
  79. },
  80. },
  81. devtool: env === 'production' ? 'source-map' : 'cheap-module-eval-source-map',
  82. devServer: {
  83. contentBase: path.join(__dirname, 'dist'),
  84. host: '0.0.0.0',
  85. port: 8888,
  86. disableHostCheck: true,
  87. },
  88. };