Ok, learning more about the loader and assets their are bugs Sweet Alert components code -
The location/name of the sourcePath is incorrect, as many of the names have ‘sweet-alert’ instead of ‘sweetalert’ which is what is being used. (look in .../vendors/sweetalert)
Also it had names referencing ‘sweet-alert’ where were changed to ‘sweetalert’
Here is the AlertAsset.php that I modifed and now works -
* Class AlertAsset
* @package yii2mod\alert
class AlertAsset extends AssetBundle
* @var string the directory that contains the source asset files for this asset bundle.
* A source asset file is a file that is part of your source code repository of your Web application.
public $sourcePath = '@bower/sweetalert/dist'; /*was lib*/
* specified in one of the following formats:
public $js = [
'sweetalert.min.js', /* was sweet-alert.min.js */
* @var array list of CSS files that this bundle contains. Each CSS file can be specified
* in one of the three formats as explained in [[js]].
public $css = [
'sweetalert.css' /* ws sweet-alert.css */
The code now in my view looks like this -
<?php echo yii2mod\alert\Alert::widget([
'useSessionFlash' => false,
'options' => [
'title' => 'Success message',
'type' => 'success', // IMPORTANT THIS IS ALL LOWER CASE, EXAMPLES SHOWN ON GITHUB IS INCORRECT
'text' => "You will not be able to recover this imaginary file!",
'confirmButtonText' => "Yes, delete it!",
'cancelButtonText' => "No, cancel!"