Skip to content

Commit

Permalink
Merge pull request #44 from david-macpherson/BF_Prod_Dev_WEBSOCKET_URL
Browse files Browse the repository at this point in the history
Bug Fix: Setting the WEBSOCKET_URL var prod and dev
  • Loading branch information
dan-tw authored Feb 26, 2024
2 parents bc4ebc4 + bb31116 commit bbb4578
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules/
types/
.vscode
!.env.example
.env
*.env
6 changes: 1 addition & 5 deletions examples/typescript/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
require('dotenv').config({ path: './.env' });
require('dotenv').config({ path: './.env' });

module.exports = {
entry: {
index: './src/index.ts',
},
plugins: [
new webpack.DefinePlugin({
WEBSOCKET_URL: JSON.stringify((process.env.WEBSOCKET_URL !== undefined) ? process.env.WEBSOCKET_URL : '')
}),
new HtmlWebpackPlugin({
title: 'Scalable Pixel Streaming Frontend',
template: './src/index.html',
Expand Down
8 changes: 7 additions & 1 deletion examples/typescript/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const webpack = require('webpack');

module.exports = merge(common, {
mode: 'development',
devtool: 'source-map',
});
plugins: [
new webpack.DefinePlugin({
WEBSOCKET_URL: JSON.stringify((process.env.WEBSOCKET_URL !== undefined) ? process.env.WEBSOCKET_URL : undefined)
}),
]
});
24 changes: 15 additions & 9 deletions examples/typescript/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const webpack = require('webpack');

module.exports = merge(common, {
mode: 'production',
optimization: {
usedExports: true,
minimize: true
},
stats: 'errors-only',
performance: {
hints: false
}
mode: 'production',
optimization: {
usedExports: true,
minimize: true
},
stats: 'errors-only',
performance: {
hints: false
},
plugins: [
new webpack.DefinePlugin({
WEBSOCKET_URL: undefined
}),
]
});
2 changes: 1 addition & 1 deletion library/src/SPSApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SPSApplication extends Application {
this.stream.setSignallingUrlBuilder(() => {

// if we have overriden the signalling server URL with a .env file use it here
if (WEBSOCKET_URL) {
if (WEBSOCKET_URL !== undefined ) {
return WEBSOCKET_URL as string;
}

Expand Down

0 comments on commit bbb4578

Please sign in to comment.