Reputation: 1447
I am using webpack dev server to serve my assets in local development. I have following in my paramters.yml.dist
# local assets devserver address
# if you want to use webpack dev server use "http://localhost:8090"
# and then > npm run devserver
assets_base_url: ~
I have following in framework for local environment.
framework:
assets:
base_urls: ["%assets_base_url%"]
My problem is that it is not working with base settings of "~" for my colleagues that are not using devserver.
Error: "" is not a valid URL
What should I do enable or disable devserver assets url by one setting in parameters.yml
Symfony docs for asset component
Upvotes: 2
Views: 1365
Reputation: 36999
Instead of put base_urls: ["%assets_base_url%"]
, you can do that in the Extension Class of your bundle.
namespace Acme\HelloBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class AcmeHelloExtension extends Extension implements PrependExtensionInterface
{
// ...
public function prepend(ContainerBuilder $container)
{
$assetBaseUrl = $container->getParameter('assets_base_url');
if (!$assetBaseUrl) {
$container->prependExtensionConfig(
'framework',
array(
'assets' => array(
'base_urls' => array($assetBaseUrl)
)
)
);
}
}
}
Inside the PrependExtensionInterface::prepend()
method you can prepends settings over config.yml
configuration.
Upvotes: 1