Asset bundle generate empty JavaScript and CSS files
namespace frontend\assets;
return [
'bundles' => [
'frontend\assets\AppAsset',
],
'targets' => [
'frontend\assets\AppAsset' => [
'basePath' => 'e:/path/yii2.loc/www',
'baseUrl' => '',
'js' => 'js/{ts}.js',
'css' => 'css/{ts}.css',
],
],
'assetManager' => [
'basePath' => 'e:/path/yii2.loc/www/assets',
'baseUrl' => '',
],
];
config.php
return [
'bundles' => [
'frontend\assets\AppAsset',
],
'targets' => [
'frontend\assets\AppAsset' => [
'basePath' => 'e:/path/yii2.loc/www',
'baseUrl' => '',
'js' => 'cache/{ts}.js',
'css' => 'cache/{ts}.css',
],
],
'assetManager' => [
'basePath' => 'e:/path/yii2.loc/www/assets',
'baseUrl' => '',
],
];
Then in console
yii asset e:\path\config.php e:\path\compressed.php
//compresed.php it's result file with name of compressed files
And in config
'assetManager' => [
'bundles' => require dirname(__DIR__) . '/assets/compressed.php',
],
CSS and JavaScript files are in a directory:
e:/path/yii2.loc/www/css
And
e:/path/yii2.loc/www/js
Bundle generate empties to:
e:/path/yii2.loc/www/cache/css and e:/path/yii2.loc/www/cache/js
What did I do wrong?
Inside your config.php, try to config component 'assetManager' like as the following LOCs:
'components' => [
'assetManager' => [
'class' => 'yii\web\AssetManager',
'basePath' => 'YOUR_BASE_PATH'
],
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With