nanxiaobei / antd-img-crop

🗡 An image cropper for Ant Design Upload
MIT License
497 stars 156 forks source link

(SSR) When using server side rendering it says document is not defined #98

Closed digz6666 closed 3 years ago

digz6666 commented 3 years ago

When using server side rendering it says document is not defined.

 ...\node_modules\antd-img-crop\dist\antd-img-crop.cjs.js:9
[1]     var style = document.createElement('style');
[1]                 ^
[1]
[1] ReferenceError: document is not defined
[1]     at __$styleInject (...\node_modules\antd-img-crop\dist\antd-img-crop.cjs.js:9:17)
[1]     at Object.<anonymous> (...\node_modules\antd-img-crop\dist\antd-img-crop.cjs.js:41:1)
[1]     at Module._compile (internal/modules/cjs/loader.js:778:30)
[1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
[1]     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
[1]     at Module.require (internal/modules/cjs/loader.js:692:17)
[1]     at require (internal/modules/cjs/helpers.js:25:18)
[1]     at eval (webpack:///external_%22antd-img-crop%22?:1:18)
[1] [nodemon] app crashed - waiting for file changes before starting...
nanxiaobei commented 3 years ago

This is related to style-loader: https://github.com/webpack-contrib/style-loader/issues/439

If you need to support SSR, you can fork and use mini-css-extract-plugin to solve this problem.