Now we have a new directory 'assets' in the project root directory. Within these directories, there are two subdirectories one for JS-files and another one where CSS-files placed to be. To execute the very first build we need to go over in our terminal and run ./node_modules/.bin/encore dev . This will create a build directory in our web-root.
If we want to use the Twig template functions to render the JS and CSS files, we need to set up some more things. Add the new \Symfony\WebpackEncoreBundle\WebpackEncoreBundle() to AppKernel.php:
In config.yml we need to add the following lines:
From now we can use the Twig Helper functions to add JS- and CSS-files to our templates like so:
There are several scripts the we can use to build our files. Have a look into package.json file.
If we want to rebuild our files every time we have changed some code, so simply use yarn watch . This will run the script in the background.