Skip to content
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

flasher global instance with webpack #5

Open
jamesj2 opened this issue Jan 28, 2022 · 1 comment
Open

flasher global instance with webpack #5

jamesj2 opened this issue Jan 28, 2022 · 1 comment

Comments

@jamesj2
Copy link

jamesj2 commented Jan 28, 2022

I'm using webpack 5 for my project and in case anyone needs this. I was able to get a global instance of Flasher working using the following method.

webpack config:

module: {
        rules: [
            {
                test: require.resolve("toastr"),
                loader: "expose-loader",
                options: {
                    exposes: ["toastr"],
                },
            },
            {
                test: require.resolve("@flasher/flasher"),
                loader: "expose-loader",
                options: {
                    exposes: ["Flasher"],
                },
            }
        ]
}

in app.js:

import toastr from "toastr";

// toastr defaults
toastr.options.timeOut = 10000;
toastr.options.closeButton = true;
toastr.options.escapeHtml = true;
toastr.options.progressBar = true;
toastr.options.closeOnHover = false;

import { default as Flasher } from "@flasher/flasher";
import { default as ToastrFactory } from "@flasher/flasher-toastr";
Flasher.getInstance().addFactory("toastr", new ToastrFactory());
@yoeunes
Copy link
Member

yoeunes commented Jan 28, 2022

Hello @jamesj2 Thank you for the tips 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants