Config#

The default bundless configuration is the following

js
1
/** @type { import('@bundless/cli').Config } */
2
module.exports = {
3
entries: ['index.html'], // entry files
4
platform: 'browser', // target platform, browser or node
5
jsx: 'react', // jsx preset
6
loader: {
7
// like esbuild.loader, it lets you import custom extensions
8
'.jpg': 'file',
9
'.jpeg': 'file',
10
'.png': 'file',
11
'.svg': 'file',
12
'.gif': 'file',
13
'.ico': 'file',
14
'.webp': 'file',
15
'.jp2': 'file',
16
'.avif': 'file',
17
'.woff': 'file',
18
'.woff2': 'file',
19
'.ttf': 'file',
20
},
21
plugins: [],
22
server: {
23
port: 3000,
24
hmr: true,
25
openBrowser: false, // opens browser on server start
26
experimentalImmutableCache: false, // makes server refresh much faster for big projects
27
},
28
prebundle: {
29
includeWorkspacePackages: [], // linked packages to prebundle, can be a boolean
30
force: false, // forces prebundling dependencies on server start
31
},
32
build: {
33
basePath: '/',
34
jsTarget: 'es2018', // target es version
35
minify: true, // run esbuild minification
36
outDir: './out', // output directory
37
},
38
}

entries#

In the prebundle phase entries are used as starting point to traverse the import graph and gather dependencies.

In the build phase they are passes to esbuild to be bundled and outputted in outDir.

platform#

Can be browser or node.

When platform is node the output files will use commonjs modules and won't bundle dependencies (files in node_modules are marked as external).

prebundle.includeWorkspacePackages#

By default bundless does not prebundle your workspace packages, this means that you can import files from your monorepo dependencies and have them reflect changes thanks to HMR.

However this won't work if your liked dependencies contains commonjs code that uses require and module.exports, in this case you should put these packages in prebundle.includeWorkspacePackages or use prebundle.includeWorkspacePackages: true

build.basePath#

If you are deploying your website to an url like http://mysite.com/path, then you should pass /path to build.basePath, all the script and link tags in the html files will fetch files from base path, the same for dynamic imports.

includeWorkspacePackages#

Extensions you import in your js and return their path

Previous
Getting started
Next
Benchmarks
Config