diff --git a/.gitignore b/.gitignore index 86e183a7..26b43c78 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ node_modules/ types/ .vscode !.env.example -.env +*.env diff --git a/examples/typescript/webpack.common.js b/examples/typescript/webpack.common.js index d8d4bb3c..454ec742 100644 --- a/examples/typescript/webpack.common.js +++ b/examples/typescript/webpack.common.js @@ -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', diff --git a/examples/typescript/webpack.dev.js b/examples/typescript/webpack.dev.js index e1d10636..6ac383ba 100644 --- a/examples/typescript/webpack.dev.js +++ b/examples/typescript/webpack.dev.js @@ -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', -}); \ No newline at end of file + plugins: [ + new webpack.DefinePlugin({ + WEBSOCKET_URL: JSON.stringify((process.env.WEBSOCKET_URL !== undefined) ? process.env.WEBSOCKET_URL : undefined) + }), + ] +}); diff --git a/examples/typescript/webpack.prod.js b/examples/typescript/webpack.prod.js index 132f8a8b..4c937e3d 100644 --- a/examples/typescript/webpack.prod.js +++ b/examples/typescript/webpack.prod.js @@ -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 + }), + ] }); diff --git a/library/src/SPSApplication.ts b/library/src/SPSApplication.ts index 5d0f328f..d225fa12 100644 --- a/library/src/SPSApplication.ts +++ b/library/src/SPSApplication.ts @@ -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; }