Open lstarky opened 7 years ago
Here's how I got it work with Aurelia & webpack
import * as Toastr from 'toastr'
toastr = Toastr.default
toastr.options = opt
Not 100% sure why it works cause you can still call functions from the imported object... but it works for me. Hope it works for you as well.
I'm having some strange problems trying to get Toastr to work with an Aurelia project. I don't know where else to ask and so I'm hoping someone can help me troubleshoot.
I installed Toastr yesterday with
npm install --save toastr
. The README says I have version 2.1.2.I added it as a dependency to aurelia.json as follows:
I created a component and imported it (
import * as toastr from 'toastr';
), and added the CSS to app.html (<require from="toastr/build/toastr.min.css"></require>
). I am successful in getting toastr alerts to show usingtoastr.success("Hello");
.First problem: Any options I set are ignored. For example, the following doesn't work and the message is still displayed in the top right corner without a close button.
If I do
toastr.success("Hello", null, {positionClass: "toast-top-left", closeButton: true});
, it works.If I try to pass the options as an object like the following, it doesn't work and the message is still displayed in the top right corner without a close button.
Second problem: I decided that maybe I'm supposed to only be using the files in the build folder. I changed my aurelia.json configuration as follows:
Now the app won't even load. I get lots of errors in the console:
Any idea what could be happening? Or how I could/should be configuring it in Aurelia? Any clues would be greatly appreciated. I think Toastr is a great repo and want to thank you for making this available.