README.md in lookbook-0.7.4 vs README.md in lookbook-0.8.0.beta.0
- old
+ new
@@ -11,11 +11,11 @@
</div>
---
<div align="center">
-<a href="#installing">Installing</a> • <a href="#previews">Previews</a> • <a href="#pages">Pages</a> • <a href="#config">Configuration</a>
+<a href="#installing">Installing</a> • <a href="#previews">Previews</a> • <a href="#pages">Pages</a> • <a href="#deployment">Deployment</a> • <a href="#config">Config</a>
</div>
---
**Lookbook gives [ViewComponent](http://viewcomponent.org/)-based projects a _ready-to-go_ development UI for navigating, inspecting and interacting with component previews.**
@@ -70,18 +70,11 @@
The `at` property determines the root URL that the Lookbook UI will be served at.
Then you can start your app as normal and navigate to `http://localhost:3000/lookbook` (or whatever mount path you specified) to view your component previews in the Lookbook UI.
-#### Mounting in Production
-If you would like to expose the Lookbook UI in production as well as in development
-
-1. Remove the `if Rails.env.development?` condition from around the mount statement in `routes.rb`
-2. Add `config.view_component.show_previews = true` to `config/environments/production.rb`
-
-
<h2 id="previews">Previews</h2>
You don't need to do anything special to see your ViewComponent previews and examples in Lookbook - just create them as normal and they'll automatically appear in the Lookbook UI. Preview templates, custom layouts and even bespoke [preview controllers](https://viewcomponent.org/guide/previews.html#configuring-preview-controller) should all work as you would expect.
> If you are new to ViewComponent development, checkout the ViewComponent [documentation](https://viewcomponent.org/guide/) on how to get started developing your components and [creating previews](https://viewcomponent.org/guide/previews.html).
@@ -683,9 +676,76 @@
The URL segment used to prefix page routes.
Default: `pages`
```ruby
config.lookbook.page_route = `docs`
+```
+
+<h2 id="deployment">Deploying in Production</h2>
+
+Lookbook is intended to be a tool for aiding the ViewComponent development process, and so is usually restricted to running only when the app is in `development` mode.
+
+However, it is possible to run Lookbook in a production environment if you wish.
+
+### Differences between development and production
+
+By default, Lookbook will behave a little differently in production than it does in development:
+
+1. Watching files for changes is disabled
+2. Parsing preview files for annotations does **not** happen at runtime. Instead the preview files must be pre-parsed via a Rake task before starting the app (much like asset precompilation).
+
+### Pre-parsing preview files
+
+Run the following command to pre-parse the preview files annotations:
+
+```
+rake lookbook:previews:preparse
+```
+
+If you wish to run this as part of your existing assets precompilation step, you can add the following into your app's `Rakefile`:
+
+```ruby
+Rake::Task['assets:precompile'].enhance do
+ Rake::Task["lookbook:previews:preparse"].invoke
+end
+```
+
+The pre-parsing of preview files will then take place every time `rake assets:precompile` is called and so will not need to be run separately.
+
+### Configuration changes for production
+
+You will also need to make sure that the following configuration changes have been made when deploying to production:
+
+1. Make sure ViewComponent is [configured to show previews in production](https://viewcomponent.org/api.html#show_previews) (by default it is disabled when not in development):
+
+```ruby
+# config/environments/production.rb
+config.view_component.show_previews = true
+```
+
+2. Remove any environment checking from around the Lookbook mounting declaration (if added as per install instructions):
+
+```ruby
+# config/routes.rb
+Rails.application.routes.draw do
+ # if Rails.env.development? <- remove
+ mount Lookbook::Engine, at: "/lookbook"
+ # end
+end
+```
+
+### Overriding production default behaviours
+
+If for some reason you wish to enable file watching or runtime preview annotation parsing in production, you can always override the default behaviour using thie following config options:
+
+```ruby
+# config/environments/production.rb
+
+# enable file-change listening
+config.lookbook.listen = true
+
+# enable runtime preview parsing
+config.lookbook.runtime_parsing = true
```
<h2 id="config">General Configuration</h2>
Lookbook will use the ViewComponent [configuration](https://viewcomponent.org/api.html#configuration) for your project to find and render your previews so you generally you won't need to configure much else separately.