Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate webpack workflow into development and production for the library and typescript example packages #25

Merged
merged 27 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ad0c309
added new webpack files
adrianZahra Mar 27, 2023
291b7e0
removed old webpack config file
adrianZahra Mar 27, 2023
790515e
added base for the webpack common file
adrianZahra Mar 27, 2023
f41c888
added base content to the dev and prod webpack files
adrianZahra Mar 28, 2023
1af870e
moddified package.json for the new build configs
adrianZahra Mar 28, 2023
7baa785
removed the old webpack common file from the example
adrianZahra Mar 28, 2023
00f006e
added webpack dev and prod
adrianZahra Mar 28, 2023
54a9a6d
updated the package.json for the typescript example
adrianZahra Mar 28, 2023
bfae2e4
updated the nade of the library variable in the example index.ts
adrianZahra Mar 28, 2023
8a487a8
added symlink to package.json in the example
adrianZahra Mar 28, 2023
447ac01
updated main location and updated npm serve command
adrianZahra Mar 29, 2023
065c7fc
updated webpack config to webpack common to make use of the dev and p…
adrianZahra Mar 29, 2023
7ff11b7
updated the websocket url env to make use of process
adrianZahra Mar 29, 2023
3492e0c
upgraded the tag workflow to use the production builder command
adrianZahra Mar 29, 2023
a27b2b9
updated the tag and pull request workflows to use the new build commands
adrianZahra Mar 29, 2023
994367b
fixed spelling mistake in the pull request workflow
adrianZahra Mar 29, 2023
0e6eff2
updated comments in accordance to comment from luke post merge
adrianZahra Mar 29, 2023
ded28fd
added env template for example and updated git ignore to accomadate this
adrianZahra Mar 29, 2023
86ddce5
updated the pull request test to test all aspects of the library and …
adrianZahra Mar 29, 2023
86695b0
added serve for dev and prod
adrianZahra Mar 29, 2023
0cbcf88
updated the index file to just import the required types
adrianZahra Mar 29, 2023
57089f6
updated the pull request test to test all aspects of the library and …
adrianZahra Mar 30, 2023
da665f8
moved env file and renamed to example also included dontenv plugin to…
adrianZahra Mar 30, 2023
ba8f90a
removed old template
adrianZahra Mar 30, 2023
4bb88df
updated index file to make use of the env if it is not empty
adrianZahra Mar 30, 2023
c8858a6
updated if statement to single queals
adrianZahra Mar 30, 2023
7d2f512
updated the git ignore file for the env.example
adrianZahra Apr 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run build
- run: npm run build-prod
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/tag-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Build SPS Frontend
run: |
cd ./examples/typescript
npm run build-all
npm run build-all-prod

# Build the Scalable Pixel Streaming Frontend Docker image from the dist directories of the packages
- name: Build the Scalable Pixel Streaming Frontend Docker image and push to Docker
Expand Down
30 changes: 25 additions & 5 deletions .github/workflows/test-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The following workflow will run when a pull request is opened, synched or reopened
# The following workflow will run when a pull request is opened, synced or reopened
# It's intent is to run a build of the package against the PR to ensure that it passes a code build check

name: test-build
Expand Down Expand Up @@ -26,10 +26,30 @@ jobs:
with:
node-version: "16.x"

# install deps for frontend and library and build both
- name: Install library and frontend deps and build
# install deps for Library and build for development
- name: Install and build library for development
working-directory: ./library
run: |
npm ci
npm run build-dev

# install deps for Library and build for production
- name: Install and build library for production
working-directory: ./library
run: |
npm ci
npm run build-prod

# install deps for Frontend and Library and build both for development
- name: Install and build library and Frontend for development
working-directory: ./examples/typescript
run: |
npm ci
npm run build-all-dev

# install deps for Frontend and Library for and build both for production
- name: Install and build library and Frontend for production
working-directory: ./examples/typescript
id: npm
run: |
npm ci
npm run build-all
npm run build-all-prod
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ dist/
node_modules/
types/
.vscode
!.env.example
.env
1 change: 1 addition & 0 deletions examples/typescript/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WEBSOCKET_URL=ws://example.com/your/ws
16 changes: 16 additions & 0 deletions examples/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
"name": "spstypescriptexample",
"version": "1.0.0",
"description": "The typescript example for consuming the Scalable Pixel Streaming Frontend",
"main": "index.ts",
"main": "./src/index.ts",
"scripts": {
"build": "npx webpack",
"build-dev": "npx webpack --config webpack.dev.js",
"build-prod": "npx webpack --config webpack.prod.js",
"watch": "npx webpack --watch",
"start": "npx webpack && open-cli ./dist/index.html",
"serve": "webpack serve",
"build-all": "cd ../../library && npm install && npm run build && cd ../examples/typescript && npm install && npm link ../../library && npm run build"
"serve-dev": "webpack serve --config webpack.dev.js",
"serve-prod": "webpack serve --config webpack.prod.js",
"symlink": "npm link ../../library",
"build-all-dev": "cd ../../library && npm install && npm run build-dev && cd ../examples/typescript && npm run symlink && npm run build-dev",
"build-all-prod": "cd ../../library && npm install && npm run build-prod && cd ../examples/typescript && npm run symlink && npm run build-prod"
},
"author": "TensorWorks Pty Ltd",
"keywords": [],
Expand All @@ -21,14 +25,15 @@
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3",
"declaration-bundler-webpack-plugin": "^1.0.3",
"dotenv": "^16.0.3",
"html-loader": "^4.2.0",
"html-webpack-plugin": "^5.5.0",
"style-loader": "^3.3.1",
"ts-loader": "^9.4.2",
"html-loader": "^4.2.0",
"typescript": "^4.9.5",
"webpack": "^5.76.1",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1",
"wepack-cli": "^0.0.1-security"
}
}
}
23 changes: 16 additions & 7 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import * as spsFrontend from "@tensorworks/libspsfrontend";
import {Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle} from "@tensorworks/libspsfrontend";

// Apply default styling from Epic's frontend
export const PixelStreamingApplicationStyles = new spsFrontend.PixelStreamingApplicationStyle();
// Apply default styling from Epic Games Pixel Streaming Frontend
export const PixelStreamingApplicationStyles = new PixelStreamingApplicationStyle();
PixelStreamingApplicationStyles.applyStyleSheet();

// websocket url env
declare var WEBSOCKET_URL: string;

document.body.onload = function () {

// Create a config object.
// Note: This config is extremely important, SPS only supports the browser sending the offer.
const config = new spsFrontend.Config({ useUrlParams: true, initialSettings: { OfferToReceive: true, TimeoutIfIdle: true } });
const config = new Config({ useUrlParams: true, initialSettings: { OfferToReceive: true, TimeoutIfIdle: true } });

// make usage of WEBSOCKET_URL if it is not empty
let webSocketAddress = WEBSOCKET_URL;
if(webSocketAddress != ""){
config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress)
}

// Create a Native DOM delegate instance that implements the Delegate interface class
const stream = new spsFrontend.PixelStreaming(config);
const spsApplication = new spsFrontend.SPSApplication({
// Create stream and spsApplication instances that implement the Epic Games Pixel Streaming Frontend PixelStreaming and Application types
const stream = new PixelStreaming(config);
const spsApplication = new SPSApplication({
stream,
onColorModeChanged: (isLightMode) => PixelStreamingApplicationStyles.setColorMode(isLightMode) /* Light/Dark mode support. */
});
Expand Down
72 changes: 72 additions & 0 deletions examples/typescript/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
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',
filename: 'index.html'
}),
],
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: [
/node_modules/,
],
},
{
test: /\.html$/i,
use: 'html-loader'
},
{
test: /\.css$/,
type: 'asset/resource',
generator: {
filename: '[name][ext]'
}
},
{
test: /\.(png|svg)$/i,
type: 'asset/resource',
generator: {
filename: 'images/[name][ext]'
}
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.svg'],
},
output: {
filename: '[name].js',
library: 'spstypescriptexample',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'dist'),
clean: true,
globalObject: 'this',
hashFunction: 'xxhash64'
},
experiments: {
futureDefaults: true
},
optimization: {
minimize: false
},
devServer: {
static: {
directory: path.join(__dirname, 'dist'),
},
},
};
77 changes: 0 additions & 77 deletions examples/typescript/webpack.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions examples/typescript/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');

module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map',
});
14 changes: 14 additions & 0 deletions examples/typescript/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = merge(common, {
mode: 'production',
optimization: {
usedExports: true,
minimize: true
},
stats: 'errors-only',
performance: {
hints: false
}
});
3 changes: 2 additions & 1 deletion library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "The Scalable Pixel Streaming Frontend Library consuming Epic Games' Pixel Streaming Frontend",
"main": "src/index.ts",
"scripts": {
"build": "npx webpack",
"build-prod": "npx webpack --config webpack.prod.js",
"build-dev": "npx webpack --config webpack.dev.js",
"watch": "npx webpack --watch",
"serve": "webpack serve"
},
Expand Down
26 changes: 26 additions & 0 deletions library/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const package = require('./package.json');
const path = require('path');
const webpack = require('webpack');

module.exports = {
entry: {
index: './src/index.ts'
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: [/node_modules/]
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
plugins: [],
output: {
path: path.resolve(__dirname, 'dist'),
globalObject: 'this'
}
};
Loading