Closed daninr closed 6 years ago
Hi @daninr,
I can't reproduce that issue with the following files (and test.svg
being a random SVG file):
/* test.css */
body {
background: url('./test.svg');
}
// webpack.config.js
const Encore = require('@symfony/webpack-encore');
Encore
.setOutputPath('build/')
.setPublicPath('/build')
.cleanupOutputBeforeBuild()
.addStyleEntry('test', './test.css')
;
module.exports = Encore.getWebpackConfig();
Is there a specific reason that made you call addLoader
for images and JS files?
These loaders are already managed by Encore by default and by adding them again you'll end-up with duplicated instances (which I suspect is causing your issue).
Same thing for the ManifestPlugin
, it should already be added automatically.
Hi @Lyrkan
Thanks for your reply.
I'm call addLoader for JS files because i'm working with ReactJS and without this configuration it breaks when compiling.
I removed ManifestPlugin and still not working.
EDIT: Now I get working removing custom loaders... you was right, it didn't work for me days ago... Thanks you very much!
I found the same bug by following the Symfony 5 tutorial. Here how I fix it:
webpack.config.js
...
.configureLoaderRule('images', (loaderRule) => {
loaderRule.options.esModule = false;
})
...
@ebuildy That shouldn't be necessary since the version of file-loader
included in Encore does not have the esModule
option yet (see https://github.com/symfony/webpack-encore/issues/678#issuecomment-566042729)
I managed to fix this in a new project, using "@symfony/webpack-encore": "^0.28.2"
, I have followed the official tutorial from symfony.com, then I had this bug, end this fixed it.
Hi @ebuildy can you share your solution? Thanks.
Hello, I'm having some troubles using Symfony4 with Encore and Webpack.
With my configuration I cannot resolve background images on my css.
I have a css file with some background images referenced:
And this is my webpack.config.js:
When I execute this command:
It generates on public/build/images two files for each referenced image:
First (with name: arrow-back.77e1028a.svg) with this content:
And second (with name: arrow-back.81414ee.svg) is the correct image, but my compiled css file is referencing to first file, and cannot resolve file... browser is thowing this error:
I also included manifest.json into Symfony4 configuration:
Can someone explain me what I'm doing wrong? I cannot find this error on documentation.