mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Update installing.md (#1349)
Add lasso configuration description for "Initializing server-rendered components", let it clearly to read and more easy in practice.
This commit is contained in:
parent
216e25764b
commit
551cf63d2e
@ -178,6 +178,25 @@ First install `lasso` and `lasso-marko`:
|
||||
npm install --save lasso lasso-marko @lasso/marko-taglib
|
||||
```
|
||||
|
||||
Next, register and config the lasso:
|
||||
|
||||
_server.js_
|
||||
|
||||
```
|
||||
var isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
// Configure lasso to control how JS/CSS/etc. is delivered to the browser
|
||||
require('lasso').configure({
|
||||
plugins: [
|
||||
'lasso-marko' // Allow Marko templates to be compiled and transported to the browser
|
||||
],
|
||||
outputDir: __dirname + '/static', // Place all generated JS/CSS/etc. files into the "static" dir
|
||||
bundlingEnabled: isProduction, // Only enable bundling in production
|
||||
minify: isProduction, // Only minify JS and CSS code in production
|
||||
fingerprintsEnabled: isProduction, // Only add fingerprints to URLs in production
|
||||
});
|
||||
```
|
||||
|
||||
Next, in your page or layout view, add the `lasso-head` and `lasso-body` tags:
|
||||
|
||||
_layout.marko_
|
||||
@ -198,8 +217,23 @@ _layout.marko_
|
||||
|
||||
Finally, configure your server to serve the static files that `lasso` generates:
|
||||
|
||||
If you're using `express`, just do:
|
||||
|
||||
_server.js_
|
||||
|
||||
```js
|
||||
app.use(require("lasso/middleware").serveStatic());
|
||||
```
|
||||
|
||||
And if `koa`, do:
|
||||
|
||||
_server.js_
|
||||
|
||||
```
|
||||
const mount = require('koa-mount');
|
||||
const serve = require('koa-static');
|
||||
|
||||
app.use(mount('/static', serve(__dirname + '/static')));
|
||||
```
|
||||
|
||||
For the full application code for the Koa and assets bundling, please see the sample: [Marko + Koa](https://github.com/marko-js-samples/marko-koa).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user