Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

window is not defined #7

Open
SoYoung210 opened this issue Oct 11, 2019 · 2 comments
Open

window is not defined #7

SoYoung210 opened this issue Oct 11, 2019 · 2 comments
Labels
✈️ SSR ssr 구현하며 발생했던 이슈들

Comments

@SoYoung210
Copy link
Owner

image

Solve

node 환경에서는 당연히 window객체가 없다.
이를 해결하려면 window를 사용하는 곳에서 전부 예외처리 해주거나, 이를 해결해주는 라이브러리를 사용하면 된다.

window-or-global 을 사용하기로 한다.

@SoYoung210
Copy link
Owner Author

But...

image

코드상에서 window를 사용하는 곳이 없음에도, window is not defined 에러를 계속 볼 수 도 있다.
이 에러 문구를 자세히 읽어보면 style-loader 관련 내용임을 알 수 있다.

아직 원인을 자세히 알수 없지만... style-loader 대신 mini-css-extract-plugin 를 사용해서 해결했다.

Ref

webpack-issue6665

@SoYoung210 SoYoung210 changed the title SSR - window is not defined window is not defined Oct 11, 2019
@SoYoung210 SoYoung210 added ✈️ SSR ssr 구현하며 발생했던 이슈들 🆘 In Progress 원인이 명확하지 않은 이슈 labels Oct 11, 2019
@SoYoung210
Copy link
Owner Author

SoYoung210 commented Oct 11, 2019

But...(1)

image

loader만 대체했을 때는 이런 이슈가 발생하게 된다.
webpack.server.js 에 아래설정을 추가해준다.

plugins: [
    new MiniCssExtractPlugin({
      filename: '[name].css',
      chunkFilename: '[name].css',
    }),
  ],

SoYoung210 added a commit that referenced this issue Oct 11, 2019
@SoYoung210 SoYoung210 removed the 🆘 In Progress 원인이 명확하지 않은 이슈 label Oct 31, 2019
SoYoung210 added a commit that referenced this issue Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✈️ SSR ssr 구현하며 발생했던 이슈들
Projects
None yet
Development

No branches or pull requests

1 participant