javihgil / assetic-rewritesf-filter-bundle
JhgAsseticRewritesfFilterBundle provides assetic filter for helping bundle resources use.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
This package is auto-updated.
Last update: 2022-02-01 12:35:51 UTC
README
Rewrites css/js bundle referenced resource urls.
Install
"repositories": [
{
"url": "git@github.com:javihgil/assetic-rewritesf-filter-bundle.git",
"type": "vcs"
}
],
"require": {
...
"javihgil/assetic-rewritesf-filter-bundle": "dev-master",
...
},
Use
Configure assetic in app/config/config.yml:
assetic:
...
filters:
rewritesf:
resource: %kernel.root_dir%/../src/Jhg/AsseticRewritesfFilterBundle/Resources/config/rewritesf.xml
apply_to: "\.(less|css|scss)$"
...
Example: css/less/sass @imports override
config.yml
assetic:
debug: "%kernel.debug%"
use_controller: true
bundles: ['ExampleBundle']
ruby: "%assetic_ruby_bin%"
filters:
rewritesf:
resource: %kernel.root_dir%/../src/Jhg/AsseticRewritesfFilterBundle/Resources/config/rewritesf.xml
apply_to: "\.(scss)$"
sass:
bin: "%assetic_compass_bin%"
compass:
bin: "%assetic_compass_bin%"
apply_to: "\.(scss)$"
View file
{% block styles %}
{% stylesheets
"@ExampleBundle/Resources/assets/styles/example.scss"
output='sass.css'
%}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
src/ExampleBundle/Resources/assets/styles/example.scss
@import '@ExampleBundle/Resources/assets/styles/variables.scss';
body {
background-color: $color !important;
}
src/ExampleBundle/Resources/assets/styles/variables.scss
$color: red;
app/Resources/ExampleBundle/assets/styles/variables.scss
$color: green;
Result
If app/Resources/ExampleBundle/assets/styles/variables.scss file exists the result is
body {
background-color: green !important;
}
Else the result is
body {
background-color: red !important;
}