Open benglass opened 11 years ago
@afishnamedsquish, looks like you're right. I've just tried to run the test application on the 1.0
branch and I caught the same issue. I'll see what we can do and give you a feedback.
@IgorTimoshenko I actually figured out what was causing this which is that when you use the @Bundle notation in your paths config you end up with an absolute path to the module that does NOT include the dev environment prefix of app_dev.php. This means that assetic's asset controller is not triggered even if you have use_controller set to true. It seems to be fixed in the 2.0 branch.
@afishnamedsquish, in the 2.0
branch the baseUrl
configuration option contains the script. I think I can port this file into the 1.0
branch but a little bit later when I'll fix a small undocumented issue.
Just switched to 2.0 and when trying to optimize in my local dev, optimization doesn't seem to be working, i.e. 404 error:
{% javascripts filter='requirejs' '@AcmeDemoBundle/Resources/public/js/src/main.js' %} {{ require_js_initialize({ 'main' : asset_url }) }} {% endjavascripts %}
I can still manually optimize via the command line no problem:
node lib/r.js -o app.build.js
Is this related? I just started using the bundle. Thanks.
@ronnbot, can you provide your bundle configuration? What is this file app.build.js
? The bundle doesn't provide such file.
app.build.js:
(function() {
return {
appDir: ".",
baseUrl: ".",
dir: "../build",
preserveLicenseComments: true,
keepBuildDir: true,
findNestedDependencies: true,
paths: {
"jquery": "lib/jquery",
"backbone": "lib/backbone",
"text": "lib/require-text",
"handlebars": "lib/handlebars",
"underscore": "lib/underscore",
"backbone-relational": "lib/backbone-relational"
},
shim: {
'lib/jquery': {
exports: '$'
},
'lib/handlebars': {
exports: 'Handlebars'
},
'lib/underscore': {
exports: '_'
},
'lib/backbone': {
deps: ['lib/underscore', 'lib/jquery'],
exports: 'Backbone'
},
'lib/backbone-relational': {
deps: ['lib/backbone']
}
},
modules: [{
name: "main/index"
}]
}
})()
Just for reference, here's the settings from config.yml:
# Require js
hearsay_require_js:
require_js_src: //cdnjs.cloudflare.com/ajax/libs/require.js/2.1.8/require.min.js
base_url: js
base_dir: '@AcmeDemoBundle/Resources/public/js'
paths:
text: '@AcmeDemoBundle/Resources/public/js/lib/require-text'
shim:
-
name: lib/jquery
exports: '$'
-
name: lib/handlebars
exports: 'Handlebars'
-
name: lib/underscore
exports: '_'
-
name: lib/backbone
deps: [ lib/underscore, lib/jquery ]
exports: 'Backbone'
-
name: lib/backbone-relational
deps: [ lib/backbone ]
optimizer:
path: '@AcmeDemoBundle/Resources/public/js/lib/r.js'
@ronnbot, do you have the file @AcmeDemoBundle/Resources/public/js/src/main.js
?
Actually, for the purpose of debugging, I created a simpler js file, test.js.
require(['lib/jquery'], function($) {
alert('done');
});
Added it to the module list in the app.build.js to make sure it still works work when manually optimizing via the command line:
modules: [{
name: "main/test"
}]
Then insert the test.js in the template:
{% javascripts filter='?requirejs' '@AcmeDemoBundle/Resources/public/js/main/test.js' %}
{{ require_js_initialize({ 'main' : asset_url }) }}
{% endjavascripts %}
When loading the page, it loads the text.js fine and I see the alert. Then using filter='requirejs' to force the optimization, I get the 404 error on the test.js file. Doesn't look like I'm missing more settings in the config.yml.
Really appreciate the help.
@ronnbot, I cannot reproduce anything in the 2.0
branch. By the way, you don't need manually run the r.js
optimizer and to write the app.build.js
file.
"By the way, you don't need manually run the r.js optimizer and to write the app.build.js file."
I know, but doing so to make sure there are no other errors.
Thanks though, now I know it should work. I'll continue to play around with the settings.
Still getting 404 because of the error 'The process has been signaled with signal "5".' from the line:
$code = $proc->run();
Happens in both branches and with or without app.build.js for branch 1. I figured out what command was being executed for that process:
/usr/local/bin/node '/PATH/TO/r.js' '-o' '/private/var/folders/49/hb10j4dn4n1bmn5tczmxlt540000gr/T/build_profileqnnggH.js'
I'm able to execute it manually on the command line. Any ideas?
@ronnbot, try to look at this issue.
@ronnbot, did you get lucky with resolving this issue?
Using the 1.0 branch (because it supports build_profie, see #43) with use_controller: true for assetic in dev environment to dynamically generate assets on page load and using the assetic filter with the production flag (see example below) I end up with 404s in dev environment. It seems the asset url should still be generated but the filter should just not be applied. Instead it seems that the asset is not generated at all but the url is returned as /js/foo.js which is not served by assetic and is a 404.