Skip to content

Webpack 5 - document is not defined #143

@schwjustin

Description

@schwjustin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions