From 42422c87834937fba4b928059e6c09e80d8a8d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Ro=CC=88=C3=9Fner?= Date: Tue, 18 Jul 2023 15:00:03 +0200 Subject: [PATCH] adopt usage.rst --- Resources/doc/usage.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Resources/doc/usage.rst b/Resources/doc/usage.rst index 8aa080c..cb04cc9 100644 --- a/Resources/doc/usage.rst +++ b/Resources/doc/usage.rst @@ -34,6 +34,22 @@ If you are using webpack and Encore to package your assets you can use the webpa Then use it simply by importing ``import Routing from 'fos-router';`` in your js or ts code +The plugin hooks into the webpack `build` and `watch` process and triggers the `fos:js-routing:dump` command automatically, +once routes have been changed. + +To avoid that, e.g. when building the frontend on a machine or docker image/layer, where no PHP is present, you can configure the +plugin to use a static dumped `routes.json` and suppress automatic recompilation of the file, by passing some options to the plugin: + +.. code-block:: js + + const FosRouting = require('fos-router/webpack/FosRouting'); + //... + Encore + .addPlugin(new FosRouting( + { target: './assets/js/routes.json' }, // <- path to dumped routes.json + false // <- set false to suppress automatic recompilation of the file + ) + ) Alternatively you can use the dump command and export your routes to json, this command will create a json file into the ``public/js`` folder: