You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creates a `bundleRenderer` instance using pre-compiled application bundle (see [Creating the Server Bundle](#creating-the-server-bundle)). For each render call, the code will be re-run in a new context using Node.js' `vm` module. This ensures your application state is discrete between requests, and you don't need to worry about structuring your application in a limiting pattern just for the sake of SSR.
81
+
Creates a `bundleRenderer` instance using pre-compiled application bundle. The `bundle` argument can be one of the following:
82
+
83
+
- An absolute path to generated bundle file (`.js` or `.json`). Must start with `/` to be treated as a file path.
84
+
85
+
- A bundle object generated by `vue-ssr-webpack-plugin`.
86
+
87
+
- A string of JavaScript code.
88
+
89
+
See [Creating the Server Bundle](#creating-the-server-bundle) for more details.
90
+
91
+
For each render call, the code will be re-run in a new context using Node.js' `vm` module. This ensures your application state is discrete between requests, and you don't need to worry about structuring your application in a limiting pattern just for the sake of SSR.
Explicitly declare the base directory for the server bundle to resolve node_modules from. This is only needed if your generated bundle file is placed in a different location from where the externalized NPM dependencies are installed.
217
+
218
+
Note that the `basedir` is automatically inferred if you use `vue-ssr-webpack-plugin` or provide an absolute path to `createBundleRenderer` as the first argument, so in most cases you don't need to provide this option. However, this option does allow you to explicitly overwrite the inferred value.
219
+
220
+
---
221
+
193
222
### directives
194
223
195
224
Allows you to provide server-side implementations for your custom directives:
@@ -220,7 +249,7 @@ Instead, it's more straightforward to run our app "fresh", in a sandboxed contex
220
249
221
250
<imgwidth="973"alt="screen shot 2016-08-11 at 6 06 57 pm"src="https://cloud.githubusercontent.com/assets/499550/17607895/786a415a-5fee-11e6-9c11-45a2cfdf085c.png">
222
251
223
-
The application bundle can be either a string of bundled code, or a special object of the following type:
252
+
The application bundle can be either a string of bundled code (not recommended due to lack of source map support), or a special object of the following type:
224
253
225
254
```js
226
255
type RenderBundle = {
@@ -230,9 +259,9 @@ type RenderBundle = {
230
259
}
231
260
```
232
261
233
-
Although theoretically you can use any build tool to generate the bundle, it is recommended to use webpack + `vue-loader` + [vue-ssr-webpack-plugin](https://github.com/vuejs/vue-ssr-webpack-plugin) for this purpose. This setup works seamlessly even if you use webpack's on-demand code splitting features such as dynamic `import()`.
262
+
Although theoretically you can use any build tool to generate the bundle, it is recommended to use webpack + `vue-loader` + [vue-ssr-webpack-plugin](https://github.com/vuejs/vue-ssr-webpack-plugin) for this purpose. The plugin will automatically turn the build output into a single JSON file that you can then pass to `createBundleRenderer`. This setup works seamlessly even if you use webpack's on-demand code splitting features such as dynamic `import()`.
234
263
235
-
The usual workflow is setting up a base webpack configuration file for the client-side, then modify it to generate the server-side bundle with the following changes:
264
+
The typical workflow is setting up a base webpack configuration file for the client-side, then modify it to generate the server-side bundle with the following changes:
236
265
237
266
1. Set `target: 'node'` and `output: { libraryTarget: 'commonjs2' }` in your webpack config.
0 commit comments