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
Error: 'window is not defined' with Webpack 4 #130
Comments
@chrishutchinson is there some magic involved with getting that fix to work? I'm getting Invalid configuration object errors |
@kavehsajjadi same here. "self" is not defined now |
i added |
In addition to the fix I outlined at the top of the issue, if you’re still getting Often wrapping these lines in a |
Starting with a hello-world React setup (no router or anything) and this (partial) Webpack config: output: {
filename: '[name].bundle.js',
path: path.join(__dirname, 'dist'),
libraryTarget: 'umd',
},
plugins: [
new StaticSiteGeneratorPlugin({ crawl: true })
], I got this error on running
Following @chrishutchinson's links, and nested ones, I resolved it by adding this to my Webpack config: output: {
globalObject: `typeof self !== 'undefined' ? self : this`
} However, now I get new errors. On running
And on running
|
Same here. The |
Still the same problem over here, is there someone with some solution ? |
up |
|
Having the same issue here with bootstrap-loader. ERROR in ./node_modules/bootstrap-loader/no-op.js (./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/style-loader!./node_modules/css-loader/dist/cjs.js?sourceMap!./node_modules/resolve-url-loader?sourceMap!./node_modules/postcss-loader/src!./node_modules/sass-loader/lib/loader.js?sourceMap!./node_modules/bootstrap-loader/lib/bootstrap.styles.loader.js?{"bootstrapVersion":4,"bootstrapCustomizations":"/Users/wendel.costa/Desktop/qantas/src/shared/styles/01_settings/_bootstrap.scss","extractStyles":true,"styleLoaders":["style-loader","css-loader?sourceMap","resolve-url-loader?sourceMap","postcss-loader","sass-loader?sourceMap"],"styles":["mixins","grid"],"scripts":false,"configFilePath":"/Users/wendel.costa/Desktop/qantas/.bootstraprc","bootstrapPath":"/Users/wendel.costa/Desktop/qantas/node_modules/bootstrap","bootstrapRelPath":"../bootstrap"}!./node_modules/bootstrap-loader/no-op.js) |
Bump |
Having the same issue. Please see webpack.config below Thanks
} |
Same issue... So is it not possible to use it with webpack-dev-server? 🤨 |
facing similar issue on frontend module build from webpack return window && document && document.all && !window.atob; |
this worked for me
as documented https://github.com/markdalgleish/static-site-generator-webpack-plugin#globals |
@coldpour. Thanks but that does not solve my issue.
There are a few other calls to
Any idea on how to solve that? |
Were you able to fix this? |
@lofimob That was many moons ago! |
Not sure if relevant, but I was working on a library meant to run in node env, and was getting this error even after setting
|
A simple
Documentation available here. |
I'm posting this issue for reference more than anything else, in case others are searching for a fix. The temporary fix is at the end, perhaps it's worth adding that to the
README
?When using this plugin with a fresh install of Webpack 4 (
4.6.0
in my test) I get the following error:Having dug into it further, it appears it is a side effect of this issue where the
umd
target generates invalid code for running inside a Node.js context.The temporary fix is detailed here, where you can add the following to your Webpack config to change the global keyword from
window
tothis
:The text was updated successfully, but these errors were encountered: