-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[modifyWebpackConfig] / Webpack ProvidePlugin: Class constructor ProvidePlugin cannot be invoked without 'new' #2327
Comments
Did anyone figure this out? |
Any updates on this - can't use the Glamor Plugin |
The glamor plugin is used on a number of sites e.g. gatsby js.org. Could you share a site reproducing your problem with the glamor plugin? |
I hit this issue when trying to add another plugin, Seeing as the glamor plugin works for most people, your issue might be a different one, but the above fix worked in my case. |
After some more investigation, I found out the problem had to do with using an older version of yarn. This was, for some reason, causing me to get a different version of webpack than my coworker, which led to me getting an error. To fix I ran:
Then it ran correctly (with no other changes) I am on macOS High Sierra. After the changes, the webpack version in the project's |
@jayalfredprufrock I've modified the default Gatsby webpack config as shown in the documentation. gatsby-node.js const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
exports.modifyWebpackConfig = ({ config, stage }, options) => {
config.loader('url-loader', {
test: /\.(jpg|jpeg|png|gif|mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: 'static/[name].[hash:8].[ext]',
},
});
switch (stage) {
case 'develop': {
config.loader('svg-sprite', {
test: /\.svg$/,
loader: 'svg-sprite-loader',
});
return config;
}
case 'build': {
config.loader('svg-sprite', {
loader: 'svg-sprite-loader',
test: /\.svg$/,
query: {
extract: true,
},
});
config.plugin('svg-sprite', () => new SpriteLoaderPlugin());
return config;
}
default: {
return config;
}
}
}; In production / build I would like to extract the file via plugin. I've used an anonymous arrow function which returns a new instance of the plugin as you suggested. error Building static HTML for pages failed
See our docs page on debugging HTML builds for help https://goo.gl/yL9lND
136 | tr: createDOMFactory('tr'),
137 | track: createDOMFactory('track'),
> 138 | u: createDOMFactory('u'),
| ^
139 | ul: createDOMFactory('ul'),
140 | 'var': createDOMFactory('var'),
141 | video: createDOMFactory('video'),
WebpackError:
- ReactDOMFactories.js:138 Parser.pp$4.raise
~/react/lib/ReactDOMFactories.js:138:1
- ReactBaseClasses.js:71 Parser.pp.unexpected
~/react/lib/ReactBaseClasses.js:71:1
- traverseAllChildren.js:21 Parser.pp$3.parseExprAtom
~/react/lib/traverseAllChildren.js:21:1
- ReactElement.js:287 Parser.pp$3.parseMaybeUnary
~/react/lib/ReactElement.js:287:1
- ReactElement.js:232 Parser.pp$3.parseExprOps
~/react/lib/ReactElement.js:232:1
- ReactElement.js:215 Parser.pp$3.parseMaybeConditional
~/react/lib/ReactElement.js:215:1
- ReactElement.js:192 Parser.pp$3.parseMaybeAssign
~/react/lib/ReactElement.js:192:1
- ReactElement.js:168 Parser.pp$3.parseExpression
~/react/lib/ReactElement.js:168:1
- ReactNoopUpdateQueue.js:9 Parser.pp$1.parseStatement
~/react/lib/ReactNoopUpdateQueue.js:9:1
- ReactBaseClasses.js:106 Parser.pp$1.parseTopLevel
~/react/lib/ReactBaseClasses.js:106:8
- index.js:80 Parser.parse
~/object-assign/index.js:80:1
- factory.js:126 Object.parse
~/create-react-class/factory.js:126:1
- emptyFunction.js:20 Parser.parse
~/fbjs/lib/emptyFunction.js:20:1
- static-entry.js:27 NormalModule.<anonymous>
.cache/static-entry.js:27:1 In development everything works fine. I also debugged my query / options ans these seam to work. The only missing part is adding the plugin. |
Hey @marcobiedermann, have you managed to get Edit : Looks like I found your plugin on npm, and it works 👌 |
Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help! |
Gatsby Version: 1.1.6
Node.js Version: v8.2.1
OS Version: macOS Sierra 10.12.6
I'm trying to use the Webpack Provide Plugin and follow the Example of the Gatsby Glamor Plugin.
Right now, I'm just trying to add the ProvidePlugin with no content at all, so this is the content of my
gatsby-node.js
:Unfortunately, this does not work:
The text was updated successfully, but these errors were encountered: