Creating Page-Specific CSS/JSEdit this page
Warning: You are browsing the documentation for Symfony 4.0, which is no longer maintained.
Read the updated version of this page for Symfony 6.1 (the current stable version).
If you're creating a single page app (SPA), then you probably only need to define
one entry in
webpack.config.js. But if you have multiple pages, you might
1 2 3 4 5 6 7 8 9 10
// webpack.config.js Encore // an existing entry .addEntry('app', './assets/js/main.js') // a global styles entry .addStyleEntry('global', './assets/css/global.scss') + .addEntry('checkout', './assets/js/checkout.js') ;
script tag for
checkout.js on the checkout page (and a
checkout.css if you import any CSS).
the checkout page will include
checkout.js, but will not include the
app.js that's used on the other pages. Think of the checkout page as its
own "app", where
checkout.js includes all the functionality you need.
page, you can create an entry that contains that code and include both that
entry and your page-specific entry. For example, suppose that the
checkout.js on the checkout page.
Be sure to create a shared entry to avoid duplicating the Webpack bootstrap logic and any shared modules.