diff --git a/docker-compose.yml b/docker-compose.yml index 694c7c1..d0e20b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: container_name: threetwo-ui env_file: ./docker-compose.env environment: - DOCKERHOST: "{{.Node.Hostname}}" + DOCKER_SOCKET_HOST: "{{.Node.Hostname}}:8051" restart: unless-stopped labels: - "traefik.enable=true" diff --git a/src/client/context/socket/socket.context.tsx b/src/client/context/socket/socket.context.tsx index 6a0a2db..1ae2809 100644 --- a/src/client/context/socket/socket.context.tsx +++ b/src/client/context/socket/socket.context.tsx @@ -8,7 +8,7 @@ import { success } from "react-notification-system-redux"; const WebSocketContext = createContext(null); export const WebSocketProvider = ({ children }): ReactElement => { const dispatch = useDispatch(); - const socketHost = process.env.DOCKERHOST + ":8051" || SOCKET_BASE_URI; + const socketHost = process.env.DOCKER_SOCKET_HOST || SOCKET_BASE_URI; const socket: Socket = io(socketHost); socket.on("connect", () => { diff --git a/webpack.config.js b/webpack.config.js index 0a2710b..6e03f17 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,99 +1,104 @@ const path = require("path"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const webpack = require("webpack"); const outputDirectory = "dist"; const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin; -module.exports = { - entry: ["babel-polyfill", "./src/client/index.tsx"], - output: { - path: path.join(__dirname, outputDirectory), - filename: "./js/[name].bundle.js", - }, - devtool: "source-map", - stats: { - children: true, - }, - module: { - rules: [ - { - test: /\.worker\.(js|ts)$/i, - use: [ - { - loader: "comlink-loader", - options: { - singleton: true, +module.exports = (env) => { + return { + entry: ["babel-polyfill", "./src/client/index.tsx"], + output: { + path: path.join(__dirname, outputDirectory), + filename: "./js/[name].bundle.js", + }, + devtool: "source-map", + stats: { + children: true, + }, + module: { + rules: [ + { + test: /\.worker\.(js|ts)$/i, + use: [ + { + loader: "comlink-loader", + options: { + singleton: true, + }, }, - }, - ], - }, - { - test: [/\.js?$/, /\.jsx?$/, /\.tsx?$/], - use: ["babel-loader"], - exclude: /node_modules/, - }, - { - enforce: "pre", - test: /\.js$/, - loader: "source-map-loader", - }, - { - test: /\.css$/i, - use: ["style-loader", "css-loader"], - }, - { - test: /\.s[ac]ss$/i, - use: [ - // Creates `style` nodes from JS strings - "style-loader", - // Translates CSS into CommonJS - "css-loader", - // Compiles Sass to CSS - "sass-loader", - ], - }, - { - test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/i, - use: [ - "file-loader?hash=sha512&digest=hex&name=img/[contenthash].[ext]", - "image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false", - ], - }, - ], - }, - resolve: { - extensions: ["*", ".ts", ".tsx", ".js", ".jsx", ".json"], - aliasFields: ["browser", "browser.esm"], - }, - devServer: { - port: 3050, - open: true, - hot: true, - proxy: { - "/api/**": { - target: "http://localhost:8050", - secure: false, - changeOrigin: true, + ], + }, + { + test: [/\.js?$/, /\.jsx?$/, /\.tsx?$/], + use: ["babel-loader"], + exclude: /node_modules/, + }, + { + enforce: "pre", + test: /\.js$/, + loader: "source-map-loader", + }, + { + test: /\.css$/i, + use: ["style-loader", "css-loader"], + }, + { + test: /\.s[ac]ss$/i, + use: [ + // Creates `style` nodes from JS strings + "style-loader", + // Translates CSS into CommonJS + "css-loader", + // Compiles Sass to CSS + "sass-loader", + ], + }, + { + test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/i, + use: [ + "file-loader?hash=sha512&digest=hex&name=img/[contenthash].[ext]", + "image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false", + ], + }, + ], + }, + resolve: { + extensions: ["*", ".ts", ".tsx", ".js", ".jsx", ".json"], + aliasFields: ["browser", "browser.esm"], + }, + devServer: { + port: 3050, + open: true, + hot: true, + proxy: { + "/api/**": { + target: "http://localhost:8050", + secure: false, + changeOrigin: true, + }, }, }, - }, - optimization: { - usedExports: false, - }, - plugins: [ - // new BundleAnalyzerPlugin(), - new HtmlWebpackPlugin({ - template: "./public/index.html", - favicon: "./public/favicon.ico", - title: "express-typescript-react", - }), - new webpack.DefinePlugin({ - "process.env.DOCKERHOST": JSON.stringify(process.env.DOCKERHOST), - }), - new MiniCssExtractPlugin({ - filename: "./css/[name].css", - chunkFilename: "./css/[id].css", - }), - ], + optimization: { + usedExports: false, + }, + plugins: [ + // new BundleAnalyzerPlugin(), + new HtmlWebpackPlugin({ + template: "./public/index.html", + favicon: "./public/favicon.ico", + title: "express-typescript-react", + }), + new webpack.DefinePlugin({ + "process.env.DOCKER_SOCKET_HOST": JSON.stringify( + process.env.DOCKER_SOCKET_HOST, + ), + }), + new MiniCssExtractPlugin({ + filename: "./css/[name].css", + chunkFilename: "./css/[id].css", + }), + ], + }; };