Comments (11)
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)
from require-css.
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.
from require-css.
@polarity has got this correct. The css
and less
modules are used in production for injection, normalization and also for dynamic loads in production . There may be a way to exclude these so that the injection is independent of the modules, but it still depends on how requirejs/r.js#412 works out.
So yes the issue is that it is looking for css
, not finding it and then trying to dynamically load it.
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 css
.
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.
from require-css.
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 mainConfigFile
at config.js.
from require-css.
after looking further, seems my build lacks the css module completely. it´s just not there, neither with a wrong id
from require-css.
Now that is odd. Can you send a copy of your build log output?
from require-css.
you mean this one?
Running "requirejs:compile" (requirejs) task
Verifying property requirejs.compile exists in config...OK
File: [no files]
importing /development/can/_pre/less/bootstrap/bootstrap.less
importing /development/can/_pre/less/bootstrap/responsive-utilities.less
importing /development/can/_pre/less/vertical-rhytm.less
importing /development/can/_pre/less/dezem-bootstrap-theme.less
importing /development/can/_pre/less/header.less
importing /development/can/_pre/less/menu.less
importing /development/can/_pre/less/main_leftright.less
importing /development/can/_pre/less/tables.less
importing /development/can/_pre/less/main_right_step_container.less
importing /development/can/_pre/less/main_right_step_overview_container.less
importing /development/can/_pre/less/main_right_step_choose_container.less
importing /development/can/_pre/less/main_right_step_finish_container.less
importing /development/can/_pre/less/main_right_step_print_container.less
importing /development/can/_pre/less/main_right_step_user_access.less
importing /development/can/_pre/less/tree.less
importing /development/can/_pre/less/print.less
importing /development/can/_pre/less/bootstrap/reset.less
importing /development/can/_pre/less/bootstrap/variables.less
importing /development/can/_pre/less/bootstrap/mixins.less
importing /development/can/_pre/less/bootstrap/scaffolding.less
importing /development/can/_pre/less/bootstrap/grid.less
importing /development/can/_pre/less/bootstrap/layouts.less
importing /development/can/_pre/less/bootstrap/type.less
importing /development/can/_pre/less/bootstrap/code.less
importing /development/can/_pre/less/bootstrap/forms.less
importing /development/can/_pre/less/bootstrap/tables.less
importing /development/can/_pre/less/bootstrap/sprites.less
importing /development/can/_pre/less/bootstrap/dropdowns.less
importing /development/can/_pre/less/bootstrap/wells.less
importing /development/can/_pre/less/bootstrap/component-animations.less
importing /development/can/_pre/less/bootstrap/close.less
importing /development/can/_pre/less/bootstrap/buttons.less
importing /development/can/_pre/less/bootstrap/button-groups.less
importing /development/can/_pre/less/bootstrap/alerts.less
importing /development/can/_pre/less/bootstrap/navs.less
importing /development/can/_pre/less/bootstrap/navbar.less
importing /development/can/_pre/less/bootstrap/breadcrumbs.less
importing /development/can/_pre/less/bootstrap/pagination.less
importing /development/can/_pre/less/bootstrap/pager.less
importing /development/can/_pre/less/bootstrap/modals.less
importing /development/can/_pre/less/bootstrap/tooltip.less
importing /development/can/_pre/less/bootstrap/popovers.less
importing /development/can/_pre/less/bootstrap/thumbnails.less
importing /development/can/_pre/less/bootstrap/media.less
importing /development/can/_pre/less/bootstrap/labels-badges.less
importing /development/can/_pre/less/bootstrap/progress-bars.less
importing /development/can/_pre/less/bootstrap/accordion.less
importing /development/can/_pre/less/bootstrap/carousel.less
importing /development/can/_pre/less/bootstrap/hero-unit.less
importing /development/can/_pre/less/bootstrap/utilities.less
importing /development/can/_pre/less/widget_diagrambox.less
/development/can/dist/optimized.js
----------------
/development/can/deps/requirejs/require.js
/development/can/deps/dezem/require-config.js
/development/can/deps/requirejs/require-css/normalize.js
/development/can/deps/requirejs/require-css/css-builder.js
/development/can/deps/requirejs/require-less/lessc.js
/development/can/deps/requirejs/require-less/lessc-server.js
/development/can/deps/requirejs/require-less/less.js
require-less/less!app/_pre/less/report_styles
/development/can/report.js
/development/can/dist/optimized.js
----------------
/development/can/deps/requirejs/require.js
/development/can/deps/dezem/require-config.js
/development/can/deps/requirejs/require-css/normalize.js
/development/can/deps/requirejs/require-css/css-builder.js
/development/can/deps/requirejs/require-less/lessc.js
/development/can/deps/requirejs/require-less/lessc-server.js
/development/can/deps/requirejs/require-less/less.js
require-less/less!app/_pre/less/report_styles
/development/can/report.js
>> RequireJS optimizer finished
Reading /development/can/dist/optimized.js...OK
Uncompressed size: 250063 bytes.
Compressed size: 59363 bytes gzipped.
from require-css.
/development/can/deps/requirejs/require-css/css-builder.js
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.
from require-css.
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:
{
excludeShallow: ['require-css/css-builder', 'require-less/lessc-server']
}
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!
from require-css.
I've amended the RequireLESS page.
from require-css.
Thanks a lot for pointing out the issue. It works now.
I have updated the example repository in case someone is having the same problem.
from require-css.
Related Issues (20)
- explanation requested
- In IE8-9 onload does not fire in the second iframe HOT 1
- [Help!]There is a problem that load the css in iframe
- Is it possible to set media type when I load css via require?
- Require CSS in the path HOT 4
- Not working relative path's with baseUrl HOT 2
- How to skip css! references in r.js builds? HOT 1
- Removing CSS files (by reading the `removeCombined` property) HOT 3
- R.js build fails with external resources defined in the "paths" config property HOT 8
- req.toUrl is undefined HOT 2
- IE9: ieCurCallback null, Object expected HOT 1
- Error load timeout for css modules HOT 2
- In css-builder.js path.dirname(config.out) got an error HOT 2
- having trouble specifying path of css to load HOT 1
- R.js - Path must be a string HOT 4
- "Script-inlined CSS Benefits" - additional info
- how to work with commonjs module HOT 1
- When loading a cdn style sheet fails,How to load a local style sheet
- require-css load css file folder name conflict with plugin name
- Loading a css file that doesn't end with ".css"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from require-css.