Khandaker Toihidul Islam
Software Engineer
Backend : PHP | Mysql | Symfony | CakePhp | Wordpress | Drupal
Frontend : Node js | Vue js | React Js | Javascript | HTML | CSS | Bootstrap
Tools , Server : Nginx | Apache | Git | Jenkins | Jira | Asana | Silenium | Spira

Images in asset Symfony 4

  1. Edit webpack.config.js after
    Encore
    .setOutputPath(‘../build/’)

Encore
    // directory where compiled assets will be stored


    .enableVersioning()
    .copyFiles({
     from: './assets/images',

     // optional target path, relative to the output dir
     to: 'images/[path][name].[ext]',

     // if versioning is enabled, add the file hash too
     //to: 'images/[path][name].[hash:8].[ext]',

     // only copy files matching this pattern
     //pattern: /\.(png|jpg|jpeg)$/
    })

2. Get the image like

<img src="{{asset('build/images/logo.svg')}}" title="" alt="">

More details : https://symfony.com/doc/current/frontend/encore/copy-files.html

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *