-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
JS still requesting CSS even after optimization #189
Comments
+1 |
👍 But on optimization, it does insert the css into the final file, and my main application runs with the injected css working, even though it's also calling for a css file that doesn't exist. But this completely breaks my individually loaded modules, because they never properly resolve, because RequireJS tries to load their css and fails, breaking the code that waits for the sub application to load. Basically I'm confused as to why it leaves the dependencies in at all? |
The module names in the bundle and in the production config have to match up for the bundle to be used. It's a common issue, troubleshooting involves looking at the names in the bundle and making sure they are of the right normalized form. |
@guybedford could you please elaborate ? what do you mean by "name" and "production config" ? My app module looks like this : define([
'lodash',
'css!client/apps/xyz/index.css'
], ... and my bootstraping code looks like this : <script src="require_build_result.js"></script>
<script>
require(['my-app-module']);
</script> Everything works well, but the css is requested (see it in network debug tab). Is something wrong ? |
OK, I think the problem is that this doesn't correctly the function stubs which are supposed to resolve the dependencies that the defines are asking for... so: define('bower_components/require-css/css!fbsCommon/src/inputs/styles/inputs',[],function(){});
define('fbsCommon/src/inputs/main',["./Input","./Checkbox","./Combobox","./IconButton","./Switch","css!./styles/inputs"],function(){ The original dependency is: "css!./styles/inputs" but what this plugin inserts into the file to resolve this is 'bower_components/require-css/css!fbsCommon/src/inputs/styles/inputs' So... I think that's the problem, although when I change them in the optimized file to what they should be it still doesn't work. I'm not sure this plugin is really doing what I thought it should in an optimized world. (Still does work great in dev :) ) |
+1 Anyone know how to workaround this at least? |
Since I didn't want ugly #! /bin/bash
echo "* starting post-build processes..."
sed -i 's/"css!/"bower_components\/require-css\/css!/g' client/all_js.concat+min.js With adding the "css" config in map {} area, then it works, no more requests to the css files. But we shouldn't need that... |
I am attempting to
r.js
-optimize a single JS file,script.js
, which includes a module definition that requires a CSS file viarequire-css
. When I run the build,script.min.js
does indeed include the CSS. But script.min.js runs on the page, it still issues a GET request to the CSS file, as well as a request tocss.min.js
.My script:
My build.js:
Pastebin of script.min.js, beautified: http://pastebin.com/F8WYA7vd — You can see the CSS at the end. It's just one style, body{color:red}
Can anyone help me figure out what I'm doing wrong here?
The text was updated successfully, but these errors were encountered: