Skip to content

Commit

Permalink
feat: move widget form back to web
Browse files Browse the repository at this point in the history
  • Loading branch information
dgwight committed Mar 8, 2021
1 parent 476c226 commit dc8253e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"build-dev": "./node_modules/.bin/webpack --config webpack.config.js",
"build": "./node_modules/.bin/webpack --config webpack.config.js --env.prod",
"dev": "cross-env APP_URL=http://localhost:8081 yarn start",
"dev": "cross-env WEB_URL=http://localhost:8080 yarn start",
"start": "./node_modules/.bin/webpack-dev-server --open"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function main (type, args) {
case 'close':
return close()
case 'setColor':
iframe.contentWindow.postMessage({ ...args, message: 'SET_COLOR' }, process.env.APP_URL)
iframe.contentWindow.postMessage({ ...args, message: 'SET_COLOR' }, process.env.WEB_URL)
return setColor(args)
default:
return
Expand All @@ -56,7 +56,7 @@ function main (type, args) {
function init ({ username, team }) {
widget.classList.remove('OtechieWidget--hide')
const teamId = team || username
const url = `${process.env.APP_URL}/${teamId}/widget`
const url = `${process.env.WEB_URL}/${teamId}/widget`
if (iframe.src !== url) {
widget.classList.remove('OtechieWidget--loaded')
iframe.src = url
Expand All @@ -81,15 +81,15 @@ function setColor ({ color }) {
}

function messageReceived (event) {
if (event.origin !== process.env.APP_URL) return
if (event.origin !== process.env.WEB_URL) return

switch (event.data.message) {
case 'CLOSE_WIDGET':
return close()
case 'SET_COLOR':
setColor(event.data)
widget.classList.add('OtechieWidget--loaded')
return event.source.postMessage({ message: 'LOAD_WIDGET', href: window.location.origin }, process.env.APP_URL)
return event.source.postMessage({ message: 'LOAD_WIDGET', href: window.location.origin }, process.env.WEB_URL)
default:
return
}
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (env) => {
: []
plugins.push(
new CopyWebpackPlugin([{ from: 'demo/' }]),
new webpack.EnvironmentPlugin({ APP_URL: 'https://app.dev-otechie.com' })
new webpack.EnvironmentPlugin({ WEB_URL: 'https://app.dev-otechie.com' })
)
return [{
mode: isDevBuild ? 'development' : 'production',
Expand Down

0 comments on commit dc8253e

Please sign in to comment.