webpacker: [4.0.0-rc.1] Javascript_asset_tag is broken
I’ve upgraded from 4.0.0-pre.3
to 4.0.0-rc.1
and now I get a really strange error in my application.slim:
Sprockets::Rails::Helper::AssetNotFound at / The asset “{"src"=>"/packs/vendor-4699109b154b54e1ef4e.js", "integrity"=>"sha256-hkCqb1IPUS4z7o4PyMRG7t3+J0U2MgbmVUty9/hviU0= sha384- En5fK1fCL66RKx2Ovx8/n6AEwom4R6OgFxxNvKdrL6nQYow56QN66K0CE0N1c2z/ sha512- nTC02x/4ytkiw9of3MH55Xm4KkZaaGnbEkqBJ+OeToZmQH+fYrasEosB95s+bvNKQ6tjtcEIe zHJE8aHCyDqSw=="}.js” is not present in the asset pipeline.
This errors seems to be caused by this call in my project:
app/views/layout/application.slim
= javascript_pack_tag 'vendor'
It seems that javascript_pack_tag
generates a hash and is incorrectly converted to a Rails include tag. It seems to think that the hash is the src
.
Edit: It might have something to do with my splitChunks configuration
This was working fine in 4.0.0-pre.3
, but now something goes wrong in manifest.rb - lookup.
environment.config.merge({
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /\/node_modules\//,
name: 'vendor',
chunks: 'all'
}
}
}
}
});
Configurations with cacheGroups
no longer work?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (23 by maintainers)
It working now. Thanks.
@jakeNiemiec Duplicate includes causes the JavaScript code to be executed twice (or as many times as the script is included). It is a waste of performance and it could indeed have side-effects on older libraries that depend on code being loaded in a specific order or utility frameworks like error handlers.
@gauravtiwari Thank you! I’m going to give it a spin!
@jakeNiemiec My configuration is the same as the second example on Webpack’s splitChunks page. It gobbles up all vendor libraries into one big pack, which is fine for my project.
@gauravtiwari Thank you for all the great work!
Made a new release, please give it a try 🙏