2017-05-24 53 views
0

我在Windows 10上安裝了Symfony/Assetic,以及使用uglifycss 0.0.27的Node.js。我從命令行獲得了版本號,沒有問題。Symfony and Assetic; NodeJS'UglifyCSS給出了一個語法錯誤

以下是我在Symfony for Assetic中的配置;

assetic: 
    debug:   '%kernel.debug%' 
    use_controller: false 
    filters: 
     cssrewrite: ~ 
     uglifycss: 
      bin: C:\Users\User\AppData\Roaming\npm\uglifycss 

而以下是我的我的CSS文件的我的樹枝模板中設置的過濾器;

{% stylesheets 'bundles/app/css/*' filter='cssrewrite, uglifycss' output='css/compiled/main.css' %} 
     <link rel="stylesheet" href="{{ asset_url }}" /> 
    {% endstylesheets %} 

當我運行PHP斌/控制檯assetic:轉儲,我收到以下錯誤

[Assetic\Exception\FilterException] 
    An error occurred while running: 
    "C:\Program Files\nodejs\\node.EXE" "C:\Users\User\AppData\Roaming\npm\uglifycss" "C:\Users\User\AppData\Local\Temp 
    \ass6151.tmp" 
    Error Output: 
    C:\Users\User\AppData\Roaming\npm\uglifycss:2 
    basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") 
      ^^^^^^^ 
    SyntaxError: missing) after argument list 
     at createScript (vm.js:56:10) 
     at Object.runInThisContext (vm.js:97:10) 
     at Module._compile (module.js:542:28) 
     at Object.Module._extensions..js (module.js:579:10) 
     at Module.load (module.js:487:32) 
     at tryModuleLoad (module.js:446:12) 
     at Function.Module._load (module.js:438:3) 
     at Module.runMain (module.js:604:10) 
     at run (bootstrap_node.js:390:7) 
     at startup (bootstrap_node.js:150:9) 
    Input: 
    .blue{ 
     background-color: orange; 
    } 

供參考,在這裏是在Assetic文件夾設置的文件夾中包含;

Node Files

回答

0

其實,uglifycss文件應指向node_modules \ uglifycss \ uglifycss。但由於某些原因,這似乎不適用於Windows。所以我去了,直接指出在配置中,現在它似乎正常工作。

#!/bin/sh 
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") 

case `uname` in 
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;; 
esac 

if [ -x "$basedir/node" ]; then 
    "$basedir/node" "$basedir/node_modules/uglifycss/uglifycss" "[email protected]" 
    ret=$? 
else 
    node "$basedir/node_modules/uglifycss/uglifycss" "[email protected]" 
    ret=$? 
fi 
exit $ret