Developer Preview — This project is in active development. APIs may change. Provide feedback
Skip to content

@salesforce/b2c-tooling-sdk / config / loadDwJson

Function: loadDwJson()

loadDwJson(options): LoadDwJsonResult | undefined

Defined in: packages/b2c-tooling-sdk/src/config/dw-json.ts:231

Loads configuration from a dw.json file.

If an explicit path is provided, uses that file. Otherwise, looks for dw.json in the startDir (or cwd). Does NOT search parent directories.

Use findDwJson() if you need to search upward through parent directories.

Parameters

options

LoadDwJsonOptions = {}

Loading options

Returns

LoadDwJsonResult | undefined

The parsed config with its path, or undefined if no dw.json found

Example

ts
// Load from ./dw.json (current directory)
const result = loadDwJson();
if (result) {
  console.log(`Loaded from ${result.path}`);
  console.log(result.config.hostname);
}

// Load from specific directory
const result = loadDwJson({ startDir: '/path/to/project' });

// Use named instance
const result = loadDwJson({ instance: 'staging' });

// Explicit path
const result = loadDwJson({ path: './config/dw.json' });

Released under the Apache-2.0 License.