From a52214bf61c216046aaab88198f1f7c99a7b750a Mon Sep 17 00:00:00 2001 From: Matthew Francis Brunetti Date: Mon, 5 Mar 2018 15:39:12 -0300 Subject: [PATCH] chore(sandbox): Organize and set some globals for convenience --- sandbox/app.js | 11 ----------- sandbox/example.js | 6 ++++++ sandbox/main.js | 5 +++++ sandbox/setGlobals.js | 11 +++++++++++ sandbox/swalWithReactContent.js | 4 ++++ webpack.config.sandbox.js | 2 +- 6 files changed, 27 insertions(+), 12 deletions(-) delete mode 100644 sandbox/app.js create mode 100644 sandbox/example.js create mode 100644 sandbox/main.js create mode 100644 sandbox/setGlobals.js create mode 100644 sandbox/swalWithReactContent.js diff --git a/sandbox/app.js b/sandbox/app.js deleted file mode 100644 index 7b7c0ac..0000000 --- a/sandbox/app.js +++ /dev/null @@ -1,11 +0,0 @@ -import swal from 'sweetalert2' -import withReactContent from '../src/main' -import { StatefulElement } from './StatefulElement' - -main().catch(console.error) - -async function main() { - const mySwal = withReactContent(swal) - - await mySwal() -} diff --git a/sandbox/example.js b/sandbox/example.js new file mode 100644 index 0000000..b3c380a --- /dev/null +++ b/sandbox/example.js @@ -0,0 +1,6 @@ +import { swalWithReactContent } from './swalWithReactContent' +import { StatefulElement } from './StatefulElement' + +export const example = async () => { + await swalWithReactContent() +} diff --git a/sandbox/main.js b/sandbox/main.js new file mode 100644 index 0000000..7a7964d --- /dev/null +++ b/sandbox/main.js @@ -0,0 +1,5 @@ +import { setGlobals } from './setGlobals' +import { example } from './example' + +setGlobals() +example().catch(console.error) diff --git a/sandbox/setGlobals.js b/sandbox/setGlobals.js new file mode 100644 index 0000000..b78199e --- /dev/null +++ b/sandbox/setGlobals.js @@ -0,0 +1,11 @@ +import swal from 'sweetalert2' +import sweetalert2ReactContent from '../src/main' +import { swalWithReactContent } from './swalWithReactContent' + +export const setGlobals = () => { + Object.assign(global, { + swal, + sweetalert2ReactContent, + swalWithReactContent, + }) +} diff --git a/sandbox/swalWithReactContent.js b/sandbox/swalWithReactContent.js new file mode 100644 index 0000000..75720b9 --- /dev/null +++ b/sandbox/swalWithReactContent.js @@ -0,0 +1,4 @@ +import swal from 'sweetalert2' +import sweetalert2ReactContent from '../src/main' + +export const swalWithReactContent = sweetalert2ReactContent(swal) diff --git a/webpack.config.sandbox.js b/webpack.config.sandbox.js index 6f49199..85db589 100644 --- a/webpack.config.sandbox.js +++ b/webpack.config.sandbox.js @@ -6,7 +6,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin') module.exports = { mode: 'development', devtool: 'cheap-module-source-map', - entry: ['babel-polyfill', require.resolve('./sandbox/app')], + entry: ['babel-polyfill', require.resolve('./sandbox/main')], output: { pathinfo: true, // Add /* filename */ comments to generated require()s in the output. filename: 'bundle.js', // This does not produce a real file. It's just a virtual path.