3

r.js optimiser can create multiple js modules as in

 modules: [
        {
            name: "main",
            exclude: [
                "infrastructure"
            ]
        },
        {
            name: "infrastructure"
        }
    ],

Is there a way to create multiple css outputs?
Because one page needs set of css files and another page needs different set of css files.

1 Answer 1

1

r.js will automatically inline contents of @import url(...) links in all .css files found in the project directory. If you structure your CSS files correctly you can achieve modularisation, for example:

page1.css

@import url("common/shared.css");
@import url("page-1-specific.css");

page2.css

@import url("common/shared.css");
@import url("page-2-specific.css");

After running through r.js page1.css and page2.css will contain actual contents of the referenced files, i.e. contents of "shared.css" will be included in both of them.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer. How do I tell r.js to create page1.css and page2.css separately? I only see cssIn, out option in the r.js documentation.
@eugene all r.js does is inline the contents, you create the files yourself. No special configuration necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.