From bd589433fc517f3d1bf5dc5b50f7f12a2a35eb9e Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Thu, 16 Jan 2020 18:50:18 +0300 Subject: [PATCH] move socket path to env --- apps/block_scout_web/assets/js/socket.js | 2 +- apps/block_scout_web/assets/webpack.config.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/assets/js/socket.js b/apps/block_scout_web/assets/js/socket.js index 3490157a8b..ef0846220b 100644 --- a/apps/block_scout_web/assets/js/socket.js +++ b/apps/block_scout_web/assets/js/socket.js @@ -1,7 +1,7 @@ import { Socket } from 'phoenix' import { locale } from './locale' -const socket = new Socket('/socket', { params: { locale: locale } }) +const socket = new Socket(process.env.SOCKET_ROOT + '/socket', { params: { locale: locale } }) socket.connect() export default socket diff --git a/apps/block_scout_web/assets/webpack.config.js b/apps/block_scout_web/assets/webpack.config.js index 07452b55c8..76abc70bee 100644 --- a/apps/block_scout_web/assets/webpack.config.js +++ b/apps/block_scout_web/assets/webpack.config.js @@ -5,6 +5,7 @@ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin') const { ContextReplacementPlugin } = require('webpack') const glob = require('glob') +const webpack = require('webpack') function transpileViewScript(file) { return { @@ -136,7 +137,10 @@ const appJs = filename: '../css/[name].css' }), new CopyWebpackPlugin([{ from: 'static/', to: '../' }]), - new ContextReplacementPlugin(/moment[\/\\]locale$/, /en/) + new ContextReplacementPlugin(/moment[\/\\]locale$/, /en/), + new webpack.DefinePlugin({ + 'process.env.SOCKET_ROOT': JSON.stringify(process.env.SOCKET_ROOT || '') + }) ] }