Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@SoYoung210
Copy link
Owner

@SoYoung210 SoYoung210 commented Oct 11, 2019

image

Solve

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

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

@SoYoung210

This comment has been minimized.

Copy link
Owner Author

@SoYoung210 SoYoung210 commented Oct 11, 2019

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

This comment has been minimized.

Copy link
Owner Author

@SoYoung210 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 added a commit that referenced this issue Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.