J
J
Joseph Kopeikin2018-08-27 18:27:28
css
Joseph Kopeikin, 2018-08-27 18:27:28

How to make nodejs convert scss to css-modules on server side?

There is such a simple component

import React, {Component} from 'react';
import {observer} from 'mobx-react';
import style from './style.scss';

@observer
export default class App extends Component {
  render() {
    return (
      <div>
        <h1 className={style.title}>Hello from App Component!</h1>
        {this.props.children}
      </div>
    );
  }
}

When you start the server, everything falls on the fact that js perceives scss as js. How to render such a component on the server side?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2018-08-28
@vitali1995

WebPack in this implementation picks up all found styles and creates a css bundle. It can be manually included in the header SSR. In general, I use JSS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question