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

前端 未结 4 1814
再見小時候
再見小時候 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 02:00

    If I got it correctly I think you are trying to use style-loader for bundling server side code.If it is the case try doing this instead of doing this:

        loader: ['style-loader', 'css-loader', 'sass-loader']
    

    Try this:

        loader: ['css-loader/locals', 'sass-loader']
    

    Style loader is not supposed to be used on the server side code. So we provide kind of a null-loader instead of css-loader and remove style loader. This should do the trick I guess.

提交回复
热议问题