Skip to content

Latest commit

 

History

History
112 lines (83 loc) · 3.6 KB

frontend.rst

File metadata and controls

112 lines (83 loc) · 3.6 KB

Managing CSS and JavaScript

Screencast

Do you prefer video tutorials? Check out the Webpack Encore screencast series.

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 create static CSS and JS files in your public/ directory directly 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 be used in any PHP application and even with other server side programming languages!

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>
  • /frontend/encore/copy-files
  • Configuring Babel </frontend/encore/babel>
  • Source maps </frontend/encore/sourcemaps>
  • Enabling TypeScript (ts-loader) </frontend/encore/typescript>

Optimizing

  • Versioning (and the entrypoints.json/manifest.json files) </frontend/encore/versioning>
  • Using a CDN </frontend/encore/cdn>
  • /frontend/encore/code-splitting
  • /frontend/encore/split-chunks
  • /frontend/encore/url-loader

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-applications>
  • 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>
  • Using Encore in a Virtual Machine </frontend/encore/virtual-machine>

Issues & Questions

  • FAQ & Common Issues </frontend/encore/faq>

Full API

Other Front-End Articles

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

frontend/*