Module server

Entrypoint Node.js SDK and is designed to parse server requests from ILC and from responses. It also provides an adapter for application bundle to work in Node.js environment.

Webpack plugins factory

This entrypoint also exposes WebpackPluginsFactory which allows you to simplify Webpack configuration for Apps/Parcels that work with ILC. See more information by the link from above.

Code examples from demo apps:

Example

Vue.js sample

const fs = require('fs');
const express = require('express');
const server = express();

const {createBundleRenderer} = require('vue-server-renderer');
const bundle = require('./dist/vue-ssr-server-bundle.json');
const clientManifest = require('./dist/vue-ssr-client-manifest.json');
const appAssets = {
spaBundle: clientManifest.all.find(v => v.endsWith('.js')),
cssBundle: clientManifest.all.find(v => v.endsWith('.css'))
};

const IlcSdk = require('ilc-sdk').default;
const ilcSdk = new IlcSdk({ publicPath: clientManifest.publicPath });

const renderer = createBundleRenderer(bundle, {
template: fs.readFileSync('./index.template.html', 'utf-8'),
clientManifest: clientManifest,
runInNewContext: false,
inject: false
});

server.get('/_ilc/assets-discovery', (req, res) => ilcSdk.assetsDiscoveryHandler(req, res, appAssets));

server.get('*', (req, res) => {
res.setHeader('Content-Type', 'text/html');

const ilcData = ilcSdk.processRequest(req);

const context = {
ilcData,
url: ilcData.getCurrentReqUrl(),
};

renderer.renderToString(context, (err, html) => {
if (err) {
// ...
return;
}

ilcSdk.processResponse(ilcData, res, {
pageTitle: context.meta.inject().title.text(),
pageMetaTags: context.meta.inject().meta.text(),
appAssets,
});
res.send(html);
});

});

Index

Modules

Classes

Interfaces

Variables

Functions

Generated using TypeDoc