assetic
assetic copied to clipboard
Less variables not imported globaly
Currently using the https://github.com/phiamo/symfony-bootstrap, and out of the box, assetic works perfectly but when we update the dependencies, the generated less file throw a 500 exception.
The main differences seems to be the upgrade on this assetic framework, can't figure out if it's related to the symfony assetic bundle.
Initial Git file
"branch-alias": {
"dev-master": "1.1-dev"
}.
Updated Git file
"branch-alias": {
"dev-master": "1.2-dev"
}.
Stack trace of the exception when loading the file through dev environment http://somehost/app_dev.php/css/f1e3c9a_mopabootstrapsandboxbundle_1.css
/*
[exception] 500 | Internal Server Error | Assetic\Exception\FilterException
[message] An error occurred while running:
'/usr/bin/node' '/tmp/assetic_lessDI7bGF'
Error Output:
NameError: variable @inputHeight is undefined in mixins.less:157:14
156 width: 100%;
157 min-height: @inputHeight; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
158 .box-sizing(border-box); // Makes inputs behave like true block-level elements
Input:
//
// Mixins
[truncated}
I can confirm this issue. Twitter bootstrap defines all variables in an separate file "variables.less". After importing they should be available in global scope for reuse. The latest Less refactorings broke the previous correct behavior.
following this
Looks like applying the less filter based on file extension causes these issues. Couldn't figure out exactly whats going on, but I guess after the latest code changes assetic started to apply the file extension based less filter even on "less internal" imports, leading to separate processing of these files.
A temporary solution for Symfony2 users is to remove the apply_to: ".less$" line in your config.yml and instead add the filter to the twig stylesheet tag. Or just downgrade you assetic to an older version "kriswallsmith/assetic": "v1.1.0-alpha4" until this is resolved.
See also https://github.com/symfony/AsseticBundle/issues/198
cvschaefer one interesting workaround I just got, was simply to disable cssembed and the less is parsed well, still don't know what's going on
I'm not sure how this is happening. Are you running both the Sass and CssEmbed filters?
I can confirm this issue. Here is my compoiser.json and the relevant part from my config.yml:
composer.json
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": {
"": "src/",
"Eve\\Api": "vendor/localhome/"
}
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "dev-master",
"twig/extensions": "dev-master",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"jms/security-extra-bundle": "dev-master",
"jms/di-extra-bundle": "dev-master",
"jms/i18n-routing-bundle": "dev-master",
"gregwar/image-bundle": "dev-master",
"knplabs/knp-menu": "dev-master",
"knplabs/knp-menu-bundle": "2.0.x-dev",
"knplabs/knp-paginator-bundle": "dev-master",
"kriswallsmith/assetic": "1.1.x-dev",
"saad-tazi/g-chart-bundle": "dev-master",
"mopa/bootstrap-bundle": "dev-master",
"mopa/bootstrap-sandbox-bundle": "dev-master",
"mopa/composer-bridge": "dev-master",
"twitter/bootstrap": "dev-master",
"liip/theme-bundle": "dev-master",
"craue/formflow-bundle": "dev-master",
"pimple/pimple": "dev-master",
"ezyang/htmlpurifier": "dev-master",
"desarrolla2/rss-client-bundle": "dev-master",
"desarrolla2/rss-client": "2.*",
"desarrolla2/cache": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"version": "master",
"name": "twitter/bootstrap",
"source": {
"url": "https://github.com/twitter/bootstrap.git",
"type": "git",
"reference": "master"
},
"dist": {
"url": "https://github.com/twitter/bootstrap/zipball/master",
"type": "zip"
}
}
}
],
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
]
},
"minimum-stability": "stable",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
}
}
config.yml
...
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
filters:
less:
node: /usr/bin/nodejs
node_paths: [/usr/lib/nodejs]
apply_to: "\.less$"
cssrewrite: ~
cssembed:
jar: %kernel.root_dir%/Resources/java/cssembed-0.4.5.jar
apply_to: "\.css$|\.less$"
max_uri_length: 524288
yui_css:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
apply_to: "\.css$"
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
...
I have the exact same issue and disabling cssembed worked for me too...
Same issue here
Same issue here
Any news about this issue? How to solve it?
Still an issue. Did anybody solve this?
We're still using Assetic. As it's dropped by Symfony 3.0 it seems to be time to move along: :disappointed:
confirmed for symfony 2.8. Why isn't that one fixed? It's major :(