R
R
RodgerFox2017-01-06 18:31:10
css
RodgerFox, 2017-01-06 18:31:10

How to get started with cssModules without server-side JS?

Have a wonderful New Year's Eve everyone!
I'll start right away with a great example, if we were to use js and render it on the server:

//...
import stylesButton from './button.css';
// код сильно сокращен, но смысл понятен
export default class button extends Component {
     render() {
        return <button className={className}>{text}</button>
    }
}

But is it possible to use modular css without rendering js code? How might it look? Now they have webpack + laravel (with their own blade template engine, can be replaced with JADE, but I also don’t know the number of entry points, because small components can call each other and there is no clear structure (I suppose it’s better to inline css for each block? Please tell me, is it even possible to do this?
It is especially not clear, it is possible to find out what components each page will consist of, which Laravel will render from separate templates. To compile not small pieces of each block, but at least somehow connect them? And how to control the renaming process for css-modules? I will have separate js components loaded for each page. They are included from the main js, which looks at the router which js is needed, but it’s kind of stupid to prescribe the necessary css components in it with handles. After all, our logic is separated, and html / css is separated from js ....
Thank you =/
ps The only sound idea (IMHO), in js, is to include the main css for each router and handles to control which components should be connected. At the same time, I get a series of json files at the output, and on their basis, when rendering, I change the block classes in the template to classes from json, but it’s not clear how it will work with the same ones, in general, tough, complicated! and for each page there will be a unique css file, which means that caching will not work light

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question