-
Notifications
You must be signed in to change notification settings - Fork 2
CLOUDP-352308 Developer experience improvements and webpack HMR support #2
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
base: master
Are you sure you want to change the base?
Changes from 9 commits
a413635
fbc1d4d
966dc28
ea4066d
c37b4f6
784551e
dde11da
c1336eb
e0b6798
b39ad05
da4ad9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "printWidth": 120, | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "semi": true, | ||
| "singleQuote": true, | ||
| "trailingComma": "es5", | ||
| "bracketSpacing": true, | ||
| "arrowParens": "always" | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| nodejs 24.10.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,75 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>redwood</title> | ||
| <style> | ||
| body { padding: 10px; } | ||
| label { display: block; margin-bottom: 5px; } | ||
| label > span { display: inline-block; font-weight: bold; min-width: 120px; padding-right: 10px; text-align: right; } | ||
| label > input { width: 210px; } | ||
| footer { margin-top: 20px; text-align: center; } | ||
| button { cursor: pointer; } | ||
| </style> | ||
| <script src="options.js"></script> | ||
| <title>redwood</title> | ||
| <style> | ||
| body { | ||
| padding: 10px; | ||
| } | ||
|
|
||
| label { | ||
| display: block; | ||
| margin-bottom: 5px; | ||
| } | ||
|
|
||
| label > span { | ||
| display: inline-block; | ||
| font-weight: bold; | ||
| min-width: 120px; | ||
| padding-right: 10px; | ||
| } | ||
|
|
||
| label > input[type='text'] { | ||
| width: 400px; | ||
| } | ||
|
|
||
| footer { | ||
| margin-top: 20px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| button { | ||
| cursor: pointer; | ||
| } | ||
| </style> | ||
| <script src="options.js"></script> | ||
| </head> | ||
| <body> | ||
| <main> | ||
| <label><span>Match URL prefix</span><input name="match"></label> | ||
| <label><span>Replace URL prefix</span><input name="replace"></label> | ||
| <label><span>Webpack Dev Server?</span><input name="wds"></label> | ||
| <label><span>Web Server Port (if using wds)</span><input name="webServerPort"></label> | ||
| <label><span>Compressed?</span><input name="compressed"></label> | ||
| <footer> | ||
| <button name="save">Save</button> | ||
| </footer> | ||
| </main> | ||
| <main> | ||
| <div> | ||
| <span>MongoCDN Presets:</span> | ||
| <input type="button" name="preset" value="Development"/> | ||
| <input type="button" name="preset" value="QA"/> | ||
| <input type="button" name="preset" value="Production"/> | ||
|
||
| </div> | ||
| <br/> | ||
| <label for="match"> | ||
|
||
| <span>Match URL prefix</span> | ||
| <input type="text" name="match" id="match"> | ||
| </label> | ||
| <br/> | ||
| <label for="replace"> | ||
| <span>Replace URL prefix</span> | ||
| <input type="text" name="replace" id="replace"> | ||
| </label> | ||
| <br/> | ||
| <label for="wds"> | ||
| <input type="checkbox" name="wds" id="wds" value="true"> | ||
| <span>Webpack Dev Server?</span> | ||
| </label> | ||
| <br/> | ||
| <label for="webServerPort"> | ||
| <span>Web Server Port (if using Webpack Dev Server)</span> | ||
| <input type="text" name="webServerPort" id="webServerPort"> | ||
| </label> | ||
| <br/> | ||
| <label for="compressed"> | ||
| <input type="checkbox" name="compressed" id="compressed" value="true"> | ||
| <span>Compressed?</span> | ||
| </label> | ||
| <footer> | ||
| <button type="button" name="save">Save</button> | ||
| </footer> | ||
| </main> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,72 @@ | ||
| setInputs = (items) => { | ||
| document.querySelector('input[name=match]').value = items.match; | ||
| document.querySelector('input[name=replace]').value = items.replace; | ||
| document.querySelector('input[name=wds]').checked = items.wds; | ||
| document.querySelector('input[name=webServerPort]').value = items.webServerPort; | ||
| document.querySelector('input[name=compressed]').checked = items.compressed; | ||
| }; | ||
|
|
||
| setPreset = (event) => { | ||
| const presets = { | ||
| Development: { | ||
| match: 'https://assets-dev.mongodb-cdn.com/mms', | ||
| replace: 'http://localhost:8081', | ||
| wds: true, | ||
| webServerPort: 8081, | ||
| compressed: false, | ||
| }, | ||
| QA: { | ||
| match: 'https://assets-qa.mongodb-cdn.com/mms', | ||
| replace: 'http://localhost:8081', | ||
| wds: true, | ||
| webServerPort: 8081, | ||
| compressed: false, | ||
| }, | ||
| Production: { | ||
| match: 'https://assets.mongodb-cdn.com/mms', | ||
| replace: 'http://localhost:8081', | ||
| wds: true, | ||
| webServerPort: 8081, | ||
| compressed: false, | ||
| }, | ||
| }; | ||
|
|
||
| setInputs(presets[event.target.value]); | ||
| }; | ||
|
|
||
| document.addEventListener('DOMContentLoaded', () => { | ||
| // Use default value color = 'red' and likesColor = true. | ||
| chrome.storage.sync.get({ | ||
| match: 'https://example.com', | ||
| replace: 'http://127.0.0.1:80', | ||
| wds: true, | ||
| webServerPort: 8080, | ||
| compressed: false | ||
| }, items => { | ||
| document.querySelector('input[name=match]').value = items.match | ||
| document.querySelector('input[name=replace]').value = items.replace | ||
| document.querySelector('input[name=wds]').value = items.wds | ||
| document.querySelector('input[name=webServerPort]').value = items.webServerPort | ||
| document.querySelector('input[name=compressed]').value = items.compressed | ||
| }) | ||
| // Use default value color = 'red' and likesColor = true. | ||
| chrome.storage.sync.get( | ||
| { | ||
| match: 'https://example.com', | ||
| replace: 'http://127.0.0.1:80', | ||
| wds: true, | ||
| webServerPort: 8080, | ||
| compressed: false, | ||
| }, | ||
| (items) => { | ||
| setInputs(items); | ||
| } | ||
| ); | ||
|
|
||
| const getInput = (name) => document.querySelector(`input[name=${name}]`).value; | ||
| const getCheckbox = (name) => document.querySelector(`input[name=${name}]`).checked; | ||
|
|
||
| const getInput = name => document.querySelector(`input[name=${name}]`).value | ||
| document.querySelectorAll('input[name=preset]').forEach((button) => { | ||
| button.addEventListener('click', setPreset); | ||
| }); | ||
|
|
||
| document.querySelector('button[name=save]').addEventListener('click', () => { | ||
| chrome.storage.sync.set({ | ||
| match: getInput('match'), | ||
| replace: getInput('replace'), | ||
| wds: getInput('wds'), | ||
| webServerPort: getInput('webServerPort'), | ||
| compressed: getInput('compressed') | ||
| }, chrome.runtime.reload) | ||
| }) | ||
| }) | ||
| document.querySelector('button[name=save]').addEventListener('click', () => { | ||
| chrome.storage.sync.set( | ||
| { | ||
| match: getInput('match'), | ||
| replace: getInput('replace'), | ||
| wds: getCheckbox('wds'), | ||
| webServerPort: getInput('webServerPort'), | ||
| compressed: getCheckbox('compressed'), | ||
| }, | ||
| chrome.runtime.reload | ||
| ); | ||
| window.close(); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "redwood", | ||
| "version": "1.0.0", | ||
| "description": "Redirect network requests for assets to test production services with local changes.", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "test": "node --test", | ||
| "test:watch": "node --test --watch" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/chrome": "^0.0.270", | ||
| "@types/node": "^24.8.1", | ||
| "prettier": "^3.6.2" | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In retrospect, it's ridiculous that we left this as a text input for as long as we did