|
1 | 1 | FAQ and Common Issues
|
2 | 2 | =====================
|
3 | 3 |
|
| 4 | +How do I deploy my Encore Assets? |
| 5 | +--------------------------------- |
| 6 | + |
| 7 | +There are two important things to remember when deploying your assets. |
| 8 | + |
| 9 | +**1) Run ``encore production``** |
| 10 | + |
| 11 | +Optimize your assets for production by running: |
| 12 | + |
| 13 | +.. code-block:: terminal |
| 14 | +
|
| 15 | + $ ./node_modules/.bin/encore production |
| 16 | +
|
| 17 | +That will minify your assets and make other performance optimizations. Yay! |
| 18 | + |
| 19 | +But, what server should you run this command on? That depends on how you deploy. |
| 20 | +For example, you could execute this locally (or on a build server), and use rsync |
| 21 | +or something else to transfer the built files to your server. Or, you could put your |
| 22 | +files on your production server first (e.g. via a git pull) and then run this command |
| 23 | +on production (ideally, before traffic hits your code). In this case, you'll need |
| 24 | +to install Node.js on your production server. |
| 25 | + |
| 26 | +**2) Only Deploy the Built Assets** |
| 27 | + |
| 28 | +The *only* files that need to be deployed to your production servers are the |
| 29 | +final, built assets (e.g. the ``web/build`` directory). You do *not* need to install |
| 30 | +Node.js, deploy ``webpack.config.js``, the ``node_modules`` directory or even your source |
| 31 | +asset files, **unless** you plan on running ``encore production`` on your production |
| 32 | +machine. Once your assets are built, these are the *only* thing that need to live |
| 33 | +on the production server. |
| 34 | + |
| 35 | +Do I need to Install Node.js on my Production Server? |
| 36 | +----------------------------------------------------- |
| 37 | + |
| 38 | +No, unless you plan to build your production assets on your production server, |
| 39 | +which is not recommended. See `How do I deploy my Encore Assets?`_. |
| 40 | + |
| 41 | +What Files Should I commit to git? And which should I Ignore? |
| 42 | +------------------------------------------------------------- |
| 43 | + |
| 44 | +You should commit all of your files to git, except for the ``node_modules/`` directory |
| 45 | +and the built files. Your ``.gitignore`` file should include: |
| 46 | + |
| 47 | +.. code-block:: text |
| 48 | +
|
| 49 | + /node_modules/ |
| 50 | + # whatever path you're passing to Encore.setOutputPath() |
| 51 | + /web/build |
| 52 | +
|
| 53 | +You *should* commit all of your source asset files, ``package.json`` and ``yarn.lock``. |
| 54 | + |
4 | 55 | My App Lives under a Subdirectory
|
5 | 56 | ---------------------------------
|
6 | 57 |
|
|
0 commit comments