config/parallel

Note

You need version 1.3.0 or newer.


Warning

This feature is currently experimental; however it is likely to become the default soon. If you want to make sure to not use this feature, even with future minor updates, you should preemptively set parallel to false in your umejs options.

When you're starting to get a lot of files, it may start to take longer to build all files. In order to help alleviate this problem, umejs can build multiple files at the same time!

Note that the benefits are not equal; for some the benfits are greater than for others. Also do note that processing in parallel has a higher performance cost. For small projects, there may not be as much benefit.

With all that out of the way: configuration is very simple. Here's a basic full example:

Warning

Setting parallel to true starts up multiple processes. These needs to be closed when you stop the server as well!

// --- Import Express and umejs ---
const ume = require('@dantenl/umejs');
const express = require('express');
const path = require('path');

// --- Initialise Express ---
const app = express();
const PORT = 3000


// --- Initialise umejs ---
const umeConfig = ume({
    parallel: true,

    contentDir: path.join(__dirname, 'blog'),
    templatePath: path.join(__dirname, 'template', 'layout.ume.html')
});

// --- Set up the umejs middleware ---
app.use('/blog/{*slug}', umeConfig);

// --- Get the server running ---
const server = app.listen(PORT, () => {
    console.log(`Server running at http://localhost:${PORT}`);
});

// --- Fully close umejs ---
process.on('SIGINT', async () => {
    server.close();
    await umeConfig.close();
    process.exit(0);
});