Symfony2 uglify CSS and JS
Symfony2 uglify CSS and JS
我正在尝试
php app/console asset:dump
来测试我的生产环境。我的css文件生成,但不是我的js文件。我有这个错误信息:
C:'wamp'www'projet>php app/console assetic:dump --env=prod --no-debug
Dumping all prod assets.
Debug mode is off.
09:48:02 [file+] C:/wamp/www/projet/app/../web/css/666.css
[Assetic'Exception'FilterException]
An error occurred while running:
"C:'Program Files'nodejs''node.EXE" "C:'wamp'www'projet'app'Resources'node_
modules'.bin'uglifycss" "C:'Users'GoeresAdmin'AppData'Local'Temp'inp3AC2.tm
p"
Error Output:
C:'wamp'www'projet'app'Resources'node_modules'.bin'uglifycss:4
case `uname` in
^^^^
SyntaxError: Unexpected token case
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
这是我的javascript块布局:
{% block javascripts %}
{# jQuery depuis le CDN de Google, ou fallback sur une copie locale #}
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
{# Tous nos javascripts avec Assetic #}
{% javascripts output='js/666.js' filter='?uglifyjs2'
'js/*.js' %}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
和我正在运行的css块:
{% block stylesheets %}
{% stylesheets output='css/666.css' filter='?uglifycss'
'css/*.css' %}
<link rel="stylesheet" href="{{asset_url}}" type="text/css" />
{% endstylesheets %}
{% endblock %}
在app.php中有这一行:
$kernel = new AppKernel('prod', false);
我的配置。yml:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
filters:
uglifyjs2:
bin: %kernel.root_dir%/Resources/node_modules/.bin/uglifyjs
uglifycss:
bin: %kernel.root_dir%/Resources/node_modules/.bin/uglifycss
编辑:我编辑我的代码使用uglify而不是YUI。但它比以前更糟糕,因为现在没有JS和CSS在prod中运行。
为uglifyjs
和uglifycss
脚本配置了错误的路径。Assetic通过Node.js的可执行文件执行这些脚本-但是您将路径配置为二进制版本的uglifyjs
和uglifycss
(它们是独立的)。
正确的配置应该是:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
filters:
uglifyjs2:
bin: %kernel.root_dir%/Resources/node_modules/uglify-js/bin/uglifyjs
uglifycss:
bin: %kernel.root_dir%/Resources/node_modules/uglifycss/uglifycss
uglifyjs
脚本的正确路径取决于您安装的版本
相关文章:
- Moment js and IOS
- Ember.js and Pagination
- Vue, Webpack, DC.js, and Finally Crossfilter
- three.js and depthFunc
- Fullpage.js and SlimScroll
- Typed.js and Fontawesome
- JS and Actionscript
- Ember.js and Twitter Bootstrap Popover
- cubism.js and Internet Explorer
- Underscore.js and noconflict
- DataTables, Ember.js and Views inside a <td>
- angular-seed web-script.js and cors
- Xpath with js and google chrome
- Node.js and SQLite3
- React.js and React Native
- Durandal JS and Google Plus Sign in Javascript API
- Velocity.js and calc() CSS function
- Cluster with Express.js and Kue.js
- Angular JS and Webservices
- Node.js and Express - 将JSON对象从SoundCloud API发送到前端使其成为字符串