Answer the question
In order to leave comments, you need to log in
How to make r.js optimizer work in conjunction with Symfony2 and HearsayRequireJsBundle?
Question, directly to those who worked with this bunch.
Used by Symfony2 and the HearsayRequireJsBundle bundle . There is practically no documentation on optimizing scripts using r.js in it, except for adding a filter.
The only thing that googled succeeded was this solution: labs.apt.no/how-i-got-the-hearsayrequirejsbundle-w...
So the problem is: when specifying a filter
{% javascripts
filter='?requirejs'
'@AcmeDemoBundle/Resources/public/js/src/main.js'
%}
{{ require_js_initialize({ 'main' : asset_url }) }}
{% endjavascripts %}
hearsay_require_js:
require_js_src: //cdnjs.cloudflare.com/ajax/libs/require.js/2.1.14/require.min.js
initialize_template: HearsayRequireJSBundle::initialize.html.twig
base_url: js
base_dir: %kernel.root_dir%/scripts
optimizer:
path: %kernel.root_dir%/../r.js
declare_module_name: true
hide_unoptimized_assets: false
options:
name: main
paths:
main: @TestCoreBundle/Resources/public/js/main
{% javascripts
filter='?requirejs'
'@TestCoreBundle/Resources/public/js/main.js'
%}
<script type='text/javascript'>
var require = {
deps: [],
callback: function() {
require(['main'], function() {
});
}
};
</script>
{{ require_js_initialize({ 'main' : asset_url, 'configure' : false })}}
{% endjavascripts %}
define([
], function(){
alert(1)
});
Answer the question
In order to leave comments, you need to log in
The easiest option is to abandon Assetic as a builder, or build via gulp / grunt. Assetic is not the best tool for building a large frontend. Or write your own filters that will already pull what you need.
what kind of mistake? In theory, in a dev environment, you should not work out this filter and require.js should be connected, no?
Make this setting
optimizer:
path: %kernel.root_dir%/../r.js
hide_unoptimized_assets: true
options:
name: main
define("main",
[], function(){
alert(1)
});
require(['main']);
hearsay_require_js:
optimizer:
hide_unoptimized_assets: false
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question