Skip to Content
Docs@utoo/packConfiguration

Configuration

@utoo/pack can be configured via utoopack.json file or through the programmatic API.

Configuration File

Create a utoopack.json in your project root:

utoopack.json
{ "mode": "production", "entry": [ { "import": "./src/index.ts", "html": { "template": "./index.html" } } ], "output": { "path": "./dist", "filename": "[name].[contenthash:8].js", "chunkFilename": "[name].[contenthash:8].js", "clean": true }, "sourceMaps": true }

Core Options

mode

Build mode, affects optimizations and defaults.

{ "mode": "production" // or "development" }
ValueDescription
developmentFaster builds, better debugging, HMR enabled
productionOptimized output, minification, tree shaking

entry

Define application entry points.

{ "entry": [ { "name": "main", "import": "./src/index.ts", "html": { "template": "./index.html", "filename": "index.html" } } ] }

output

Configure output settings.

{ "output": { "path": "./dist", "filename": "[name].[contenthash:8].js", "chunkFilename": "[name].[contenthash:8].js", "publicPath": "/", "clean": true } }
OptionDescription
pathOutput directory
filenameEntry chunk filename template
chunkFilenameNon-entry chunk filename template
publicPathPublic URL path for assets
cleanClean output directory before build

define

Build-time variable replacement.

{ "define": { "process.env.NODE_ENV": "\"production\"", "__VERSION__": "\"1.0.0\"" } }

externals

Exclude dependencies from the bundle.

{ "externals": { "react": "React", "react-dom": "ReactDOM" } }

resolve

Module resolution configuration.

{ "resolve": { "alias": { "@": "./src", "@components": "./src/components" }, "extensions": [".ts", ".tsx", ".js", ".jsx"] } }

Programmatic API

const { build } = require('@utoo/pack'); await build({ mode: "production", entry: [{ import: "./src/index.ts" }], output: { path: "./dist" } });

For the full configuration schema, see config_schema.json .

Last updated on