Skip to content
On this page

Configuring Hizzy

When running hizzy from the command line, Hizzy will automatically try to resolve a config file in the current directory. It will try to resolve these files in order and find the first one that exists:

  • /hizzy.json
  • /hizzy.config.json
  • /hizzy.config.ts
  • /hizzy.config.js
  • /hizzy.config.mts
  • /hizzy.config.mjs

The most basic config file looks like this:

js
// hizzy.config.js
export default {
    // config options
};

Note that, to use ES modules syntax, either your file should end with .mjs or in the package.json you should set "type" to "module".

You can also explicitly specify a config file to use with the --config CLI option (resolved relative to cwd):

bash
hizzy --config=my-config.js
OptionsDescriptionDefault
devToggles the development modetrue
portThe port to listen on(negative means random)-1
fileRefreshWhether the HMR should work or nottrue
autoBuildIf enabled, builds on start in production modetrue
listenWhether it should automatically listen or nottrue
mainThe main file located in the src folder"Server.jsx"
mainModuleWhether the main file is a modulejs file or nottrue
baseHTMLThe base HTML file located in the src folder(optional)index.html
allowAllPackagesWhether it should allow client to load any package in node_modulesfalse
checkConfigWhether it should complete the config file(only for JSON)true
realtimeWhether it should create a socket server or nottrue
staticCheck Static Asset HandlingObject or Array
httpsWhether the connection is secure or notfalse
srcFolderThe folder to use for source files"src"
connectionTimeoutThe maximum time for a socket to connect in ms(negative means off)60000
keepaliveTimeoutThe server-sided maximum keepalive time in ms(negative means off)30000
clientKeepaliveThe client-sided maximum keepalive time in ms(negative means off)20000
minClientKeepaliveWhat's the minimum keepalive time in ms(negative means off)8000
addonsCheck Using AddonsObject or Array
includeOriginalInBuildWhether the build file should have a backuptrue
cacheCheck CachingObject

Config Intellisense

Since Hizzy ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:

js
/** @type {import("hizzy").UserConfig} */
export default {
    // ...
};

Alternatively, you can use the Hizzy.defineConfig helper which should provide intellisense without the need for jsdoc annotations:

js
export default Hizzy.defineConfig({
    // ...
});

Hizzy also directly supports TS config files. You can use hizzy.config.mts with the defineConfig helper as well.

Conditional Config

If the config needs to conditionally determine options based on the mode:

js
export default Hizzy.defineConfig(({isDev}) => {
    if (isDev) {
        return {
            // dev specific config
        };
    } else {
        return {
            // build specific config
        };
    }
});

Async Config

If the config needs to call async functions, it can export an async function instead. And this async function can also be passed through defineConfig for improved intellisense support:

js
export default Hizzy.defineConfig(async ({command, mode}) => {
    const data = await asyncFunction();
    return {
        // hizzy config
    };
});

Using Environment Variables in Config

Environmental Variables can be obtained from process.env as usual.

js
export default Hizzy.defineConfig({
    // hizzy config
    something: process.env.thing
});

Released under the MIT License. (dev)