Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
John McLaughlin committed Mar 24, 2016
1 parent d1fbfcb commit 90e05f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# LoopBack + webpack build example

This is a fork of the [Getting started with LoopBack](http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack) tutorial demonstrating how to build a LoopBack application with [webpack](https://webpack.github.io/). Specifically we handle issues relating to [loopback-boot](https://apidocs.strongloop.com/loopback-boot/) and associated dynamic module dependencies.
This is a fork of the [Getting started with LoopBack](http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack) tutorial demonstrating how to build a LoopBack application with [`webpack`](https://webpack.github.io/). Specifically we handle issues relating to [`loopback-boot`](https://apidocs.strongloop.com/loopback-boot/) and associated dynamic module dependencies.

This follows the general outline of [Simon Degraeve](https://github.com/SimonDegraeve)'s [loopback-webpack-plugin](https://github.com/SimonDegraeve/loopback-webpack-plugin) which appears to have been abandoned and no longer working. We also draw on ideas from [webpack-node-externals](https://github.com/liady/webpack-node-externals).
This follows the general outline of [Simon Degraeve](https://github.com/SimonDegraeve)'s [`loopback-webpack-plugin`](https://github.com/SimonDegraeve/loopback-webpack-plugin) which appears to have been abandoned and no longer working. We also draw on ideas from [`webpack-node-externals`](https://github.com/liady/webpack-node-externals).

This could be developed into a webpack plugin at some point, but as an example it's clearer to configure webpack this way.

The key features of the approach are:
* Rather than call `boot()` at runtime, we perform a `loopback-boot` *compile* at build time and store the resulting *boot instructions* as a bundled JSON resource.
* At runtime, we just call the `loopback-boot` executor to perform the boot. This avoids many problems trying to bundle the compiler and also provides much faster boot times for complex applications.
* All of the boot-time resources are specified in a `ContextReplacementPlugin` by providing a single *dependency map* that resolves all of the resources specified in the boot instructions. This feature of `ContextReplacementPlugin` is [currently undocumented](https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin).
* All of the boot-time resources are specified in a [`ContextReplacementPlugin`](https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin) by providing a single *dependency map* that resolves all of the resources specified in the boot instructions. This feature of `ContextReplacementPlugin` is currently undocumented.
* No need for browserify!
* We specify which `node_modules` dependencies will be bundled (internalized) and which will not. `loopback-boot/lib/executor` must be bundled so webpack can handle resolution of models, boot scripts, etc.
* Dynamic configuration files (such as `config.json` and `datasources.json`) are excluded from the bundle (externalized) so that they can be modified without re-building.
* [gulp](http://gulpjs.com) is used trivially to perform the build.
* [`gulp`](http://gulpjs.com) is used trivially to perform the build.

#### Installation

Expand Down

0 comments on commit 90e05f3

Please sign in to comment.