R Lopez
R Lopez

Reputation: 199

Config webpack encore for symfony

I have created a symfony project. For manage the js and the css I use webpack encore as advised in symfony official. And in dev environment, everyhting works well. yarn run encore dev create correct path for my asset.

An example of my html

link href="{{ asset('build/page-connexion/connexion.css') }}" 

the request URL for that is

http://localhost:8000/build/footer/footer.css

But in production when I run "yarn run encore production" the path is not correct the request url for the footer is

http://mydomain.fr/build/footer/footer.css

it should be http://mydomain.fr/mywebsite/public/build/footer/footer.css

How and where can I configure this path? in my HTACCESS?

I know that if I change setPublicPath('myfullpath') with the path of my server in the webpack.config.js it will works. But logically i don't have to change it?

Thanks in advance for your help

Upvotes: 0

Views: 650

Answers (1)

Vitalii Harbulinskyi
Vitalii Harbulinskyi

Reputation: 41

public is root directory for your webserver. And if you configured setOutputPath and setPublicPath in webpack.config.js you need just add link href="{{ asset('your_entry_point.css') }}" to html code. Also you can check entrypoints.json this file will contain all paths for your entrypoints.

Upvotes: 1

Related Questions