extract-css-chunks-webpack-plugin icon indicating copy to clipboard operation
extract-css-chunks-webpack-plugin copied to clipboard

Fix errors when accessing document global on server

Open unverbraucht opened this issue 4 years ago • 1 comments

When using the plugin in a server-side rendering context there is no document global where script or link tags could be added to. In this case typically all scripts and link tags are collected and added by the renderer itself so nothing needs to be executed by the plugin on require.

This patch detects the existence of the document global and skips adding nodes if it doesn't exist. Also fixed test cases. Feedback welcome, maybe there is a better way to do this?

unverbraucht avatar Feb 19 '21 12:02 unverbraucht

This should also fix #296

unverbraucht avatar Feb 19 '21 12:02 unverbraucht