diff --git a/package.json b/package.json index 315b52c..241ccde 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/widget.js b/src/widget.js index e44ee66..43ab3e2 100644 --- a/src/widget.js +++ b/src/widget.js @@ -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 @@ -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 @@ -81,7 +81,7 @@ 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': @@ -89,7 +89,7 @@ function messageReceived (event) { 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 } diff --git a/webpack.config.js b/webpack.config.js index db6c5ac..54c1f36 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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',