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

Webpack 5 - document is not defined #143

Open
schwjustin opened this issue May 1, 2022 · 1 comment
Open

Webpack 5 - document is not defined #143

schwjustin opened this issue May 1, 2022 · 1 comment

Comments

@schwjustin
Copy link

In my webpack.config.js file I have:

output: {
    ...
    libraryTarget: "umd",
    globalObject: "this",
},

...

new StaticSiteGeneratorPlugin({
    locals: {},
    globals: {
        window: {},
    },
}),
ERROR in ReferenceError: document is not defined
    at evalmachine.<anonymous>:127444:36
    at evalmachine.<anonymous>:127466:13
    at evalmachine.<anonymous>:133637:12
    at webpackUniversalModuleDefinition (evalmachine.<anonymous>:3:20)
    at evalmachine.<anonymous>:10:3
    at Script.runInContext (node:vm:139:12)
    at Script.runInNewContext (node:vm:144:17)
    at module.exports (/Users/justinschwartz/Documents/GitHub/chrome-extension/node_modules/eval/eval.js:84:12)
    at /Users/justinschwartz/Documents/GitHub/chrome-extension/node_modules/static-site-generator-webpack-plugin/index.js:42:22
    at fn (/Users/justinschwartz/Documents/GitHub/chrome-extension/node_modules/webpack/lib/Compilation.js:509:9)

webpack 5.72.0 compiled with 1 error in 47986 ms
@Patysko
Copy link

Patysko commented Apr 27, 2023

Add to globals document you can mock that with JS-DOM library
globals: { document: {}, },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants