Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 16 additions & 4 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@size-limit/esbuild-why": "^8.2.4",
"@size-limit/preset-small-lib": "^8.2.4",
"@types/jest": "^29.5.1",
"@types/node": "^25.6.0",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"eslint": "^8.39.0",
"husky": "^8.0.3",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const domainMatcher = /^(www|newsapp)\.abc\.net\.au$/;

// Checks if a proxy is requested for this project and loads it if required.
// The returned promise will only resolve if no proxy is loaded.
export const proxy = (project: string) =>
export const proxy = (project: string, options: { type?: string } = {}) =>
new Promise<number>((resolve, reject) => {
// Never run on live/production.
if (
Expand All @@ -24,6 +24,6 @@ export const proxy = (project: string) =>
// Load in a cheaky management keyboard shortcut
import('./main').then(({ manager, init }) => {
manager();
init(project).then(resolve).catch(reject);
init(project, options).then(resolve).catch(reject);
});
});
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ declare global {
}
}

export const init = (project: string): Promise<RESOLUTION_REASONS> => {
export const init = (
project: string,
options: { type?: string } = {}
): Promise<RESOLUTION_REASONS> => {
return new Promise((resolve, reject) => {
// If we're already in a dev environment, there's nothing to do here.
if (process.env.NODE_ENV === 'development') {
Expand Down Expand Up @@ -43,6 +46,9 @@ export const init = (project: string): Promise<RESOLUTION_REASONS> => {

const scr = document.createElement('script');
scr.src = src;
if (options.type) {
scr.type = options.type;
}
document.head.appendChild(scr);
const msg = '[dev-proxy] Loaded script: ' + src + ` (${project})`;
console.info(msg);
Expand Down
Loading