Skip to content

Latest commit

 

History

History
108 lines (79 loc) · 3.51 KB

frontend.rst

File metadata and controls

108 lines (79 loc) · 3.51 KB

Managing CSS and JavaScript

Symfony ships with a pure-JavaScript library - called Webpack Encore - that makes working with CSS and JavaScript a joy. You can use it, use something else, or just create static CSS and JS files in your web/ directory and include them in your templates.

Webpack Encore

Webpack Encore is a simpler way to integrate Webpack into your application. It wraps Webpack, giving you a clean & powerful API for bundling JavaScript modules, pre-processing CSS & JS and compiling and minifying assets. Encore gives you professional asset system that's a delight to use.

Encore is inspired by Webpacker and Mix, but stays in the spirit of Webpack: using its features, concepts and naming conventions for a familiar feel. It aims to solve the most common Webpack use cases.

Tip

Encore is made by Symfony and works beautifully in Symfony applications. But it can easily be used in any application... in any language!

Encore Documentation

Getting Started

  • Installation </frontend/encore/installation>
  • First Example </frontend/encore/simple-example>

Adding more Features

  • CSS Preprocessors: Sass, LESS, etc </frontend/encore/css-preprocessors>
  • PostCSS and autoprefixing </frontend/encore/postcss>
  • Enabling React.js </frontend/encore/reactjs>
  • Enabling Vue.js (vue-loader) </frontend/encore/vuejs>
  • Configuring Babel </frontend/encore/babel>
  • Source maps </frontend/encore/sourcemaps>
  • Enabling TypeScript (ts-loader) </frontend/encore/typescript>

Optimizing

  • Versioning (and the manifest.json file) </frontend/encore/versioning>
  • Using A CDN </frontend/encore/cdn>
  • Creating a "Shared" entry for re-used modules </frontend/encore/shared-entry>

Guides

  • Using Bootstrap CSS & JS </frontend/encore/bootstrap>
  • Creating Page-Specific CSS/JS </frontend/encore/page-specific-assets>
  • jQuery and Legacy Applications </frontend/encore/legacy-apps>
  • Passing Information from Twig to JavaScript </frontend/encore/server-data>
  • webpack-dev-server and Hot Module Replacement (HMR) </frontend/encore/dev-server>
  • Adding custom loaders & plugins </frontend/encore/custom-loaders-plugins>
  • Advanced Webpack Configuration </frontend/encore/advanced-config>

Issues & Questions

  • FAQ & Common Issues </frontend/encore/faq>
  • /frontend/encore/versus-assetic

Full API

Assetic

Assetic is a pure PHP library that helps to process & optimize your assets (similar to Encore). Even though we recommend using Encore, Assetic still works great. For a comparison, see /frontend/encore/versus-assetic.

For more about Assetic, see /assetic.

Other Front-End Articles

frontend/encore/installation frontend/encore/simple-example frontend/encore/*

frontend/*