鍍金池/ 問答/HTML/ nodejs 報(bào)錯(cuò): SyntaxError: Unexpected token

nodejs 報(bào)錯(cuò): SyntaxError: Unexpected token {

服務(wù)端中渲染react的時(shí)候,組件引用css文件報(bào)錯(cuò)

import './index.css'
SyntaxError: D:/code/node/my-express-react-reactRouter/src/components/header/index.css: Unexpected token, expected ; (1:5)
> 1 | html {
    |      ^
  2 |   background: red;
  3 | }
  4 | 

該怎么解決?

回答
編輯回答
無標(biāo)題

已解決
在服務(wù)端入口使用了一個(gè)css的鉤子就沒報(bào)錯(cuò)了,具體原因不

require('css-modules-require-hook')({
  extensions: ['.css'],
  generateScopedName: '[name]__[local]-[hash:base64:8]',
});

參考代碼https://stackoverflow.com/que...

2017年8月9日 04:49