The default bundless configuration is the following
1/** @type { import('@bundless/cli').Config } */2module.exports = {3entries: ['index.html'], // entry files4platform: 'browser', // target platform, browser or node5jsx: 'react', // jsx preset6loader: {7// like esbuild.loader, it lets you import custom extensions8'.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},21plugins: [],22server: {23port: 3000,24hmr: true,25openBrowser: false, // opens browser on server start26experimentalImmutableCache: false, // makes server refresh much faster for big projects27},28prebundle: {29includeWorkspacePackages: [], // linked packages to prebundle, can be a boolean30force: false, // forces prebundling dependencies on server start31},32build: {33basePath: '/',34jsTarget: 'es2018', // target es version35minify: true, // run esbuild minification36outDir: './out', // output directory37},38}
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.
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).
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
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.
Extensions you import in your js and return their path