Unlock this challenge:
Because we like dinosaurs, I've created the following file:
// assets/dinosaur.js console.log('RAAWR 🦖');
Scary! Assuming we have a standard Encore setup, how could we get this code to run on our page?
In base.html.twig, also add encore_entry_script_tags('dinosaur')
base.html.twig
encore_entry_script_tags('dinosaur')
Update webpack.config.js to have this line:
webpack.config.js
.addEntry('dinosaur', './assets/dinosaur.js')
Add this to app.js:
app.js
import './dinosaur';
It's automatic! Any JavaScript in the assets/ directory will be included when calling encore_entry_script_tags('app').
assets/
encore_entry_script_tags('app')