'window is not defined' error when using style-loader with webpack

前端 未结 4 1810
再見小時候
再見小時候 2020-12-11 01:16

Building a server side react app and while using Webpack I am having issues with Style-Loader.

I am using version \"^0.23.1\" and when running a script to bundle and

4条回答
  •  北海茫月
    2020-12-11 01:57

    style-loader tries to inject styles into the head of the website (window / document), which will be non-existent on your server on render / execution.

    You need to remove this loader from your server-config and replace it with something else (e.g. ExtractTextPlugin or MiniCSSExtractplugin, depending on your webpack version)

提交回复
热议问题