Skip to content

Commit d731679

Browse files
committed
fix issue#33
1 parent b59d821 commit d731679

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## V2.3.1
2+
3+
- Fix [issue#33](https://github.com/indooorsman/esbuild-css-modules-plugin/issues/33)
4+
15
## V2.3.0
26

37
- **V2**: upgrade `@parcel/css` to `1.9.0`

lib/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const buildInjectCode = (injectToSelector = 'head', css, digest, options) => {
4848
(function(){
4949
const css = \`${css}\`;
5050
const doInject = () => {
51+
if (typeof document === 'undefined') {
52+
return;
53+
}
5154
let root = document.querySelector('${injectToSelector}');
5255
if (root && root.shadowRoot) {
5356
root = root.shadowRoot;

lib/v1.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ const buildCssModulesJs = async (cssFullPath, options) => {
5555
if (inject === true) {
5656
injectedCode = `
5757
(function() {
58+
if (typeof document === 'undefined') {
59+
return;
60+
}
5861
if (!document.getElementById(digest)) {
5962
var el = document.createElement('style');
6063
el.id = digest;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "esbuild-css-modules-plugin",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "A esbuild plugin to bundle css modules into js(x)/ts(x).",
55
"main": "./index.js",
66
"types": "./index.d.ts",

0 commit comments

Comments
 (0)