I’m building an electron
app. In it, I have a webview
with a preload
script. Inside said script, I’d like to use sweetalert
.
I installed sweetalert
with npm install --save sweetalert
. Inside my script I load it with require('sweetalert')
and call it with swal("Hello world!");
. I now notice it doesn’t look right, as the alert is missing its required CSS file. But I’m loading it with require('sweetalert')
, which is great since sweetalert
can just remain in its directory inside node_modules
and I don’t have to care for it, but its CSS is an integral part of it, and is not getting pulled the same way.
Now, what is the recommended way of solving this? Keep in mind I’m inside a javascript
file and would like to remain that way. Do I really have to go get the CSS file and inject it in some way? And how would I do it correctly, since it is inside node_modules
? After testing it, it seems like it can’t be done in this particular case due to Content Security Policy.
Either way, that seems so clunky in comparison to the require
statement, it’d seem weird for a simpler solution to not be available.