-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
TypeError: Cannot read property 'toWebpackConfig' any property #2875
Comments
Similar issue after upgrading a 5.2 Rails application to Webpacker 6. Have ruled out that is an issue with custom configs: Steps to reproduce. Follow the Webpacker readme. Use Rails 5.2.3.
Thanks. |
You may want to remove your Or follow https://github.com/rails/webpacker/blob/master/6_0_upgrade.md |
Thanks, @scottrobertson, that was helpful. How one goes about adding custom loader configs as this seems to have changed in v6 as well. With webpacker v5, one could add a module loader like this:
The above config is no longer compatible with webpacker 6! Also, a plugin definition pattern like the following is also broken:
So all of these needs to be rewritten in v6. |
As v6 is still in beta, the docs haven't been finalized yet, but— For adding loaders and/or plugins, you could try this approach: const { webpackConfig, merge } = require('@rails/webpacker')
// define additional loader rules
const loaders = [
{
test: /\.ejs$/,
loader: 'underscore-template-loader',
options: {...}
},
// ... more loader rules
]
// initialize additional plugins
const plugins = [
new webpack.ProvidePlugin({
...
}),
// ... more plugins
]
// merge with default webpack config
// and export result
module.exports = merge(
webpackConfig,
{
module: {
rules: loaders
},
plugins: plugins,
}
) You can find more info in the webpack configuration docs and the webpack-merge docs (for the special webpack-aware merge function). |
Thanks @rossta |
What would I do if I'm getting this error on webpacker 4.0 and don't want/can to upgrade to 6.x? |
I would open an issue with steps to replicate it, as it won't be related to this. |
This will probably go without saying for some users, but, after |
Reopen the issue webpack/webpack-cli#2342 while it doesn't belong to webpack-cli (although is from [webpack-cli] reported): Cannot read property 'toWebpackConfig'
config/webpack/environment.js
config/webpack/production.js
package.json
The text was updated successfully, but these errors were encountered: