Webpack-encore: Wrong entrypoints.json path

Created on 29 Jan 2019  路  16Comments  路  Source: symfony/webpack-encore

I'm having troubles with getting Webpack Encore to work nicely. I'm running Symfony 4.2.1 and followed the instructions. It's working fine, but getting the links for stylesheets and scripts with the "encore_entry_link_tags" tag doesn't work. It compiles just fine with all files in the correct folder.

Due to my host I need to use "public_html" as directory. I changed it in the composer.json file and the website is working fine. However, when using tags for rendering the tags is not working.

An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "C:/redacted/website/public/build/entrypoints.json" does not exist.").

So here Webpack thinks it should be in public/build, but it should be public_html/build. What am I missing? Webpack is putting the files in the right folder with this config:

// directory where compiled assets will be stored
.setOutputPath('public_html/build/')
// public path used by the web server to access the output path
.setPublicPath('/build')

I must be missing something obvious and small here... Tried to change the setPublicPath with public_html in front, but nothing seems to change when I edit that. Any ideas?

Most helpful comment

Did you change the output_path in WebpackEncoreBundle config? It should be located in config/packages/webpack_encore.yaml and look like this:

webpack_encore:
    # The path where Encore is building the assets.
    # This should match Encore.setOutputPath() in webpack.config.js.
    output_path: '%kernel.project_dir%/public_html/build'

All 16 comments

Did you change the output_path in WebpackEncoreBundle config? It should be located in config/packages/webpack_encore.yaml and look like this:

webpack_encore:
    # The path where Encore is building the assets.
    # This should match Encore.setOutputPath() in webpack.config.js.
    output_path: '%kernel.project_dir%/public_html/build'

Thanks for the quick response. Woops, I forgot that. But still it's the same. I've cleared all the cache and ran Encore again via Yarn. Same error.

Edit: the weird thing is, when I change it to public_html2, the error changes to the right path (but with the 2 that's faulty obviously, when I use public_html it will use public... Isn't that weird?

Really strange... As soon as I change the directory in the yaml it gives an error about the path I entered. But as soon as I move the folders to the new path I get the old error with the public/build directory...

Anyone?

Hi @Gerben321,

Is the entrypoints.json file generated in the right directory?
If that's the case then the problem is not on Encore's side and changing your webpack.config.js is not needed (nor is rebuilding your assets).

It could however be an issue with the Webpack Encore Bundle configuration as pointed out by @jmsche.

What you are describing is a bit weird... if you set the output_path to public_html it should definitely look for the file in that directory, not in public...

Does it also fail if you put output_path: '%kernel.project_dir%/public_html2/build' and tell Encore to create the files in that directory?

Thanks for commenting @Lyrkan,

Yes the entrypoints.json file is in the correct directory.

If I change the output_path to public_html2 like you said, it will give the error that it can't find the entrypoints.json in the public_html2 directory. That's good, because you'd say it's looking there. So then I try to change my webpack.config.js and generate the files in the public_html2 directory. I then reload the page and it mentions public again, not public_html or public_html2. So as soon as the directory is right it will give an error about the wrong folder... What's this magic?

Welp, that's even weirder... "public" is not hardcoded anywhere in the Webpack Encore Bundle, so there is no reason for it to use that string...

Is the error message the exact same one ? An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "C:/redacted/website/public/build/entrypoints.json" does not exist."). ?

If you search for public in your Symfony config files, do you find anything?

Hang on, maybe I've not spent alot of attention to the error!

When I use the correct output_path in webpack_encore.yaml I get this:
An exception has been thrown during the rendering of a template ("Asset manifest file "C:\bla/public/build/manifest.json" does not exist.").

But when I use the wrong path I get this:
An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "C:\bla/public_html2/build/entrypoints.json" does not exist.").

So the first one is output_path: '%kernel.project_dir%/public_html/build'
The second one is output_path: '%kernel.project_dir%/public_html2/build'

Nothing else with public can be found in the whole project. I've started with a fresh install of Symfony 4.2 and installed the needed packages I needed, nothing big and all official Symfony stuff. I don't have other projects with a different public folder, so not sure if it works anywhere else. But this is so strange. Everything works great though if I manually set the JS and CSS files, but I'd rather not do that ofcourse.

Not the same error then, one is related to entrypoints.json and the other one for manifest.json :)
If it switches to the manifest.json error, your output_path and setOutputPath() values are probably right.

That new error is not caused by the Encore Webpack Bundle but by the Asset component when you configure it to use the JSON Manifest Strategy.

You probably have a json_manifest_path key somewhere in your config files that doesn't contain the right path.

Oh duh! Sorry about that, overlooked the error as being the same. I uncommented the json_manifest_path in assets.yaml and it's working now. Sorry for the trouble!

Hello, I don't want to make a new issue but I was hoping you could possibly help. I am having the same problem as described above. I have json_manifest_path working correctly, recently upgrading from Webpack 2 to Webpack 4 due to this new functionality.

The file is correctly created in the correct directory (web/build/admin/manifest.json) from my webpack config. However, Symfony is still looking in the public directory for it. It finds the entrypoints.json file just fine.

webpack_encore:
    output_path: '%kernel.project_dir%/web/build/mdb'
    builds:
        admin: '%kernel.project_dir%/web/build/admin'

framework:
    assets:
        packages:
            admin:
                json_manifest_path: '%kernel.project_dir%/web/build/admin/manifest.json'



md5-fe404206c6bee92ffaa41656a8e13a87



        {{ encore_entry_script_tags('app', null, 'admin') }}
        {{ encore_entry_link_tags('app', null, 'admin') }}



md5-70c1a2a491c612654cfa331574d167a2



An exception has been thrown during the rendering of a template ("Asset manifest file "/var/www/html/public/build/manifest.json" does not exist.").

It appears webpack encore does not take into account the asset package names? Thanks for your help.

Hi @Emirii,

Two different files here: the entrypoints.json and the manifest.json.

The first one (entrypoints.json) is only used by the Webpack Encore Bundle, for instance when you're calling {{ encore_entry_script_tags(...) }} and {{ encore_entry_link_tags(...) }}.

The second one (manifest.json) is not used by the Webpack Encore Bundle but by the Asset component, for instance when calling {{ asset(...) }} in your Twig.

The cause of the error you are getting could be that there is a json_manifest_path defined directly under framework.assets somewhere in your config files and that you are calling asset(...) without specifying a package name in your Twig (which makes it use the default package).

Thanks Lyrkan. I upgraded my entire project and it looks like Symfony Flex had added another assets.yml file with that config, exactly what you said! Works wonderfully now. Thank you.

Posting this in case others make this simple mistake!

we need to change the path in config/packages/webpack_encore.yaml

webpack_encore:
    output_path: '%kernel.project_dir%/public_html/build'

cheers

Same problem Symfony 5.1.7. I created a new example project.

webpack_encore:
    output_path: '%kernel.project_dir%/web/build'

entrypoints.json and manifest.json are correct. Still access to public instance of web

I'm going through this wonderful issue right now. So fun. I've about had it all I get with symfony nothing works, the docs leave too much out etc. I've had nothing but problems with symfony.

Was this page helpful?
0 / 5 - 0 ratings