-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Images in >0.30 in manifest have hashed path #808
Comments
@darrylhein can you share the diff of your yarn.lock file for this upgrade (https://www.npmjs.com/package/yarn-lock-diff can probably be used to generate a summary of the upgrade) ? |
As discussed on Slack with @4c0n, it seems to be related to shellscape/webpack-manifest-plugin#209 We updated the A quick workaround would be to change that value to Encore.configureUrlLoader({
images: {
limit: 0, // Avoids files from being inlined
esModule: false
}
}); |
@Lyrkan Thanks for looking into it so fast 😄 I'm just using copyFiles() in the webpack.config.js file to get the right result for now. |
@stof Here's the "diff". I only changed the encore version in the package.json and then did I've tried @Lyrkan's suggestion, but didn't fix things and it appears to have removed the image files from the manifest all together. I could just copy the files, but I'd like them to be run through the svgo-loader. Thanks for the help so far. |
With the |
Ah! I half ignored your code. Putting in just I'm not exactly sure what this means – do we call this resolved? Should we document this somewhere? Or is it just something specific to my project config? |
That'd depend on the version of the
Nah, that's definitely a bug, not sure what we can do on our side though (apart from setting |
"By default, file-loader generates JS modules that use the ES modules syntax. There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking." https://webpack.js.org/loaders/file-loader/ I'm not really understanding why exactly it's causing the issue at hand though. The description seems rather unrelated? |
If it's actually |
I don't think the |
Alright, how about excluding the version until it's fixed then? Currently there apparently are compatibility issues that prevent this project from working properly. We should not just ignore that until the problem goes away, right? |
Sadly this isn't that simple. There is no reason to exclude a version of the We could change that default value to Also it could introduce breaking changes since ES6 imports do not always behave the same way than CommonJS imports (see my comment here). Some people already had to change their code when that feature was introduced in 0.29.0. At the end of the day, yes, that's definitely an issue, but there are some workarounds while waiting for it to be fixed upstream:
|
I mean excluding the version of |
Because all versions of the |
it is not |
Alright I see the issue now. Had a quick look at the plugin repo and there hasn't been any activity there since December 2019. The author/maintainer isn't responding to the issue at all. Looks like the package will be abonded if it's not already. 😭 |
@4c0n & @Lyrkan : You might want to look into webdeveric/webpack-assets-manifest. It is actively maintained and looks like it has all the features you need. As an example, the following config: // webpack.config.js
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const WebpackAssetsManifest = require('webpack-assets-manifest')
module.exports = {
entry: {
front: './front.js',
},
output: {
filename: 'js/[name].[contenthash].js',
publicPath: '/assets/dist/',
},
optimization: {
runtimeChunk: 'single',
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].[contenthash].css',
}),
new WebpackAssetsManifest({
publicPath: true,
entrypoints: true,
integrity: true,
}),
],
module: {
rules: [
{
test: /\.css$/,
use: [
{loader: MiniCssExtractPlugin.loader},
{loader: 'css-loader', options: {url: true}},
]
},
{
test: /\.(jpe?g|png|svg|gif)$/,
use: [
{loader: 'file-loader', options: {name: 'img/[name].[contenthash].[ext]'}},
],
},
],
},
} // front.js
import './front.css' /* front.css */
.foo {
background: url("example.jpg");
} Produces the following manifest: {
"entrypoints": {
"front": {
"js": [
"/assets/dist/js/runtime.67a91499be4cb5c00239.js",
"/assets/dist/js/front.8699e2b0dd20e58cd32a.js"
],
"css": [
"/assets/dist/css/front.dfe5f8bceb27844d87f9.css"
]
}
},
"front.css": {
"src": "/assets/dist/css/front.dfe5f8bceb27844d87f9.css",
"integrity": "sha256-hM/uAmUiFoVk54BH7wSa67FQOzYVMfL1dmVF8AOB1Xc= sha384-S/Pezexz+pGQ4igWksSiNbnJP6dueIPuw9JQdVvfIcRU6lOlCV7wjxov0Wyda6SJ sha512-79NZNneIGLgIJCrwA9TIZbcW0lKgypFzvI+nH+nd3NUV2KOdqH9A+XDuh2UBW+dpAQcqBPr2jyJDry505Jg4FQ=="
},
"front.js": {
"src": "/assets/dist/js/front.8699e2b0dd20e58cd32a.js",
"integrity": "sha256-GK5U8n5yDd5kUpE0bq8Mi2LiZTBD+i8EtLBKfL6uIIg= sha384-Oa1vMIiynZKkI7VZd4/LaVbiOmyrfWWNgEILZXyUJK/oGEsANK7GoQQOSfO5TsLP sha512-ZFQCD/gud1Sf8vEPGeDEHNH8KBqDGjCplqALEhVY4WESHDGB0zbCK1IZbx6hxi/JfLzCdjYNk1HH/YLqmxa4KA=="
},
"img/example.jpg": {
"src": "/assets/dist/img/example.31d6cfe0d16ae931b73c59d7e0c089c0.jpg",
"integrity": "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= sha384-OLBgp1GsljhM2TJ+sbHjaiH9txEUvgdDTAzHv2P24donTt6/529l+9Ua0vFImLlb sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg=="
},
"runtime.js": {
"src": "/assets/dist/js/runtime.67a91499be4cb5c00239.js",
"integrity": "sha256-B5W3PUqfVixDW5RqL7xk9wbdMA7BtOyW9XO6++la61I= sha384-bQ4/nZ2qJ9hFDPtL1EAWTWhBJMJjraH6ja53ndlszok/VzFHK8NGTChLVGkdVG1X sha512-EPbDbwy4jKbZVDOpi0aHuzOtqT1twmX9tRWObHO1N0/K9UC4TXp5adZoh9AilXBuh/ayW4BOajsgO4JGk8f1fw=="
}
} |
Seems great to me. The variant that is currently used is abandoned, I tried reaching out to both the owner, who said he would try to get in touch with the maintainers, and the last maintainer, but that didn't lead to anything productive unfortunately. |
Some update guys? |
I think we're having the same problem. Until now we used:
And now
@Lyrkan Could you please give me an example on how to disable the esModule option? |
I found another fix/workaround: It's based on the new
The default reges of the The regex I use will work for 8, 16, 24 and 32 character long hashes so you, @darrylhein, should be able to use it too, as your hashes seem to be 8 characters long. This still feels a little weird but it works and I don't have to disable the |
Hey, thanks for your report! |
When I update to >=0.30 (works fine in 0.29.1) the keys for images in the manifest are the hashed versions instead of the original paths. (I suspect fonts will be the same.) Prior to 0.30 I get:
After 0.30 I get:
...which of course doesn't work :(
I'm import the image in my JS files.
I'm wondering if this is related to #771 though I'm still have the issue with 0.30.2.
I can reproduce the issue when updating webpack-encore (and sass-loader) on https://github.com/xmmedia/starter_wordpress
Let me know what other information you need.
The text was updated successfully, but these errors were encountered: