Skip to content

Commit

Permalink
fix: some improvements for example onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
carloscarvallo committed Jan 26, 2021
1 parent 5f84b7d commit 3a5d235
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
TOKY_API_URL="https://api.toky.co"
TOKY_RESOURCES_URL="https://app.toky.co"
PUSHER_KEY=""
PUSHER_KEY=""
# only for development
# your Toky Agent id account
AGENT_ID=""
53 changes: 29 additions & 24 deletions build-utils/webpack.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin

module.exports = () => ({
plugins: [
new BundleAnalyzerPlugin({ analyzerPort: 8889 }),
new HtmlWebpackPlugin({
// target template to copy the structure from
template: 'example/template.html',
// insert the bundle to the head so we can run the initialization script after it
inject: 'head',
// used for cache refreshing
hash: true,
}),
new ForkTsCheckerWebpackPlugin({
async: true,
}),
],
devServer: {
// since our index.html is located in the dist folder, we need to provide different content bases
contentBase: ['example/'],
port: 8080,
publicPath: 'http://localhost:8080/',
hot: true,
watchContentBase: true,
},
})
module.exports = (mode, dotenv) => {
const agent_id = JSON.parse(dotenv.definitions['process.env.AGENT_ID'])
return {
plugins: [
new BundleAnalyzerPlugin({ analyzerPort: 8889, openAnalyzer: false }),
new HtmlWebpackPlugin({
// target template to copy the structure from
template: 'example/template.html',
// insert the bundle to the head so we can run the initialization script after it
inject: 'head',
// used for cache refreshing
hash: true,
}),
new ForkTsCheckerWebpackPlugin({
async: true,
}),
],
devServer: {
// since our index.html is located in the dist folder, we need to provide different content bases
contentBase: ['example/'],
port: 8080,
publicPath: 'http://localhost:8080/',
hot: true,
watchContentBase: true,
open: true,
openPage: `?agent_id=${agent_id}`,
},
}
}
6 changes: 6 additions & 0 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ async function main() {
* REDIRECT BEGIN
* ref: https://toky-js-sdk.toky.co/docs/single-sign-on
*/
if (!currentAppId) {
generalMessage.textContent =
'app_id has to be provided in the main.js example file, contact Toky support for more details'
generalArticle.classList.add('is-danger')
return
}
window.location.replace(
`${tokySsoURL}/auth/sso/login/${currentAppId}?redirect_url=${encodeURIComponent(
window.location.href
Expand Down
7 changes: 4 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const gitRevisionPlugin = new GitRevisionPlugin()

const libraryName = 'toky-sdk-alpha'

const modeConfig = (env) => require(`./build-utils/webpack.${env}`)(env)
const modeConfig = (env, dotenv) =>
require(`./build-utils/webpack.${env}`)(env, dotenv)

const getEnvFile = function (key) {
const files = {
Expand All @@ -17,7 +18,7 @@ const getEnvFile = function (key) {
'dev-bundle': '.env.dev',
}

return files[key] || files.master
return files[key] || files.dev
}

module.exports = ({ mode, presets } = { mode: 'production', presets: [] }) => {
Expand Down Expand Up @@ -69,6 +70,6 @@ module.exports = ({ mode, presets } = { mode: 'production', presets: [] }) => {
*/
// externals: ['sip.js'],
},
modeConfig(mode)
modeConfig(mode, dotenv)
)
}

0 comments on commit 3a5d235

Please sign in to comment.