Typescript server rendering introduces css error

import * as React from "react";
import { connect } from "react-redux";
import * as CSSModules from "react-css-modules";
const styles = require("./index.css")
const Home = () => {
  return (
    <div>
    11111
  </div>
  )
}

export default connect(state=>state)(CSSModules(Home, styles))

the error is as follows

clipboard.png

import * as styles from "./index.css";

clipboard.png

if you write index.css.d.ts, the error is shown in figure 1.

ask the bosses


it is obvious that the CSS you loaded cannot be parsed according to the syntax of JS, which is obvious in the prompt.


is such an obvious mistake that you can't see it?


ignore css in the node environment by overriding require.extensions [ext] , or you can use the off-the-shelf library: https://www.npmjs.com/package.

.
Menu