-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
after (correct) building, optimized.js wants to load less.js #63
Comments
I'm facing a similar problem. My optimized project tries to load css.js. I created a repo with a sample project: https://github.com/rangermeier/require-css-example All JavaScript and CSS should be packaged to optimized/main.js. When opening optimized/index-optimized.html the inlined CSS is correctly injected but require still attempts to load optimized/css.js (which fails) and optimized/example/example.css (which works but is superfluous because all styles are already injected) |
I think the problem "could be" a ordinary path problem. but i still not solved the problem. i analyzed the build a bit: the css-builder writes some new modules into the build, like this (when separateCSS== true): define('less!widgets/mywidget',[],function(){}); then, theres the module that requires it: define('widgets/mywidget/module',['less!../errorhandler.less'],function() {
// my code
}); requirejs now looks for the required (css/less block) module. when its not loaded (or found because of a wrong path/id) he tries to load it from a url. So at first it tries to load/look for for the less! plugin, which is not present. About changing paths and config the whole day, im on the way to create a grunt task to clean the build from all less! require strings and fake modules. |
@polarity has got this correct. The So yes the issue is that it is looking for The reason this breaks in your case is because the configuration is being injected AFTER the CSS in the layer. So that RequireJS doesn't know where to find One fix I can do for this is to use the ID "require-css/css!" in the plugin that is built into the layer so it can work without the configuration injection. But it would still need to know the paths configuration, which would break this approach. So I think this is a problem of configuration injection - you need to ensure you get it built in higher up. If you manually move the configuration in the built main.js to just below RequireJS, it will work fine. I would follow this up as an r.js issue - configuration is an area I think is having quite a bit of work in the next release, so good to get these points in now. |
Ok I managed to sort this out by changing main.js to look like: require(["config"], function() {
require(["example/example"]);
}); config.js: require.config({
baseUrl: ".",
paths: {
"require-css": "lib/require-css"
},
map: {
"*": {
"css": "require-css/css"
}
}
}); And then build.js referencing |
after looking further, seems my build lacks the css module completely. it´s just not there, neither with a wrong id |
Now that is odd. Can you send a copy of your build log output? |
you mean this one?
|
Ahh, this would be the pluginBuilder issue again - note the build info at the bottom of the RequireLESS page. Include the following config: {
excludeShallow: ['require-css/css-builder', 'require-less/lessc-server', 'require-less/lessc'],
include: ['require-css/css']
} Until issue requirejs/r.js#289 is addressed there is nothing I can do about this. |
yea that seems to work, the build loads like a charme 💃 i tried the excludeShallow option already, but the note on the build info at the bottom of the RequireLESS page says:
maybe it should be updated with all needed files and a hint that it´s meant to be on the build config not the requirejs frontend config. just to make it clear. thx for your quick help and great work! |
I've amended the RequireLESS page. |
Thanks a lot for pointing out the issue. It works now. |
i can´t figure out why the build want´s to load it. i have already an optimized.css/js as output but a part of the optimized.js want´s to load a "less.js". any idea how to avoid that?
The text was updated successfully, but these errors were encountered: