[SOLVED] Publishing assets to a CDN application end

G’day all

In my Yii2 Advanced site I’ve created a CDN end for all static resources. Almost all of that is working as desired however I’m stuck on re-defining yii\web\YiiAsset to publish to my CDN. I’d like it to publish to http://cdn.example.com/assets instead of to the assets folder of the active app. I’ve tried…


'yii\web\YiiAsset' => [

	'baseUrl' => '//cdn.example.com/assets',

],



&


'yii\web\YiiAsset' => [

	'baseUrl' => '@cdn/web/assets',

],



in bundles within my config but neither appears to have any effect. Any suggestions?

Cheers,

Pedro :)

Solved!

Instead of redefining YiiAsset as above, I’ve achieved the desired result by globally setting the basePath & baseUrl properties of the AssetManager as follows…


	'assetManager' => [

                'basePath' => '@cdn/web/assets',

		'baseUrl' => '//cdn.example.com/assets',

		'bundles' => [

			...

		],

	],