Build commands
These commands will allow you to generate the code that can be used to run or analyze a Frontity project
The build process
When you do npx frontity build you generate a build folder with several files.
You'll get something similar to this:
βββ build
β βββ analyze
β β βββ module-development.html
β β βββ server-development.html
β βββ bundling
β β βββ chunks.module.json
β β βββ entry-points
β β βββ server.ts
β β βββ my-frontity-project
β β βββ client.ts
β βββ server.js
β βββ static
...
β βββ xxxxx1.module.js
β βββ xxxxx2.module.jsThe most important file for deployments in any hosting is server.js, which is actually a middleware that can be inserted in a custom web server.
How to execute a Frontity project in production after the build
npx frontity serve
npx frontity serveYou can directly execute this server.js by using the command npx frontity serve.
So, easy way of executing a Frontity project in any Node.js server:
Launch remotely
npx frontity buildto generate thebuildfolder.Launch remotely
npx frontity serveto launch a web server that makes use of theserver.jsgenerated in the previous step.
Using server.js as a middleware
server.js as a middlewareYou can also use this generated server.js as part of a custom server like it's mentioned here.
// lambda.js
const awsServerlessExpress = require("aws-serverless-express");
const app = require("./build/server.js").default;
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => {
awsServerlessExpress.proxy(server, event, context);
};The bundle analyzer
Frontity generates some reports automatically by using Webpack Bundle Analyzer.
When doing npx frontity build you get a build folder in the root of your project.
βββ build
β βββ analyze
β β βββ module-development.html
β β βββ server-development.html
β βββ bundling
β β βββ chunks.module.json
β β βββ entry-points
β β βββ my-frontity-project
β β β βββ client.ts
β β βββ server.ts
β βββ server.js
β βββ static
β βββ my-frontity-project.module.js
β βββ list.module.jsInside that build folder there is a .html file generated at analyze/module-development.html. This file is a visual report in the form of a tree generated by Webpack Bundle Analyzer.

This report shows you the modules included on each bundle and the size of each one, so that you can analyze them and maybe decide using other modules (or not including a specific module at all) to reduce the size of the final bundle.
Last updated
Was this helpful?