@addison
To include CSS in Symfony 5, you can follow these steps:
1 2 3 4 5 6 7 |
Encore .setOutputPath('public/build/') .setPublicPath('/build') .addStyleEntry('css/main', './public/css/main.css') .cleanupOutputBeforeBuild() .enableSourceMaps(!Encore.isProduction()) .enableVersioning(Encore.isProduction()) |
In this example, main.css
is the name of your CSS file. You can change it to match the name of your CSS file.
1 2 3 |
{% block stylesheets %} {{ encore_entry_link_tags('css/main') }} {% endblock %} |
Make sure to replace main
with the name you specified in the webpack.config.js
file.
1
|
$ yarn encore dev |
If you don't have Yarn installed, you can use the following command instead:
1
|
$ npm run encore dev |
That's it! Your CSS file should now be included in your Symfony application. You can also use this method to include multiple CSS files by repeating steps 1-5 for each file.