Skip to content

Commit

Permalink
Update Snaps CLI documentation (#1178)
Browse files Browse the repository at this point in the history
* Update Snaps CLI

* document options

* minor fixes

* Update snaps/reference/cli/options.md

Co-authored-by: Maarten Zuidhoorn <[email protected]>

* remove bundler from example configs

* address reviewer feedback and re-remove submodule

---------

Co-authored-by: Christian Montoya <[email protected]>
Co-authored-by: Maarten Zuidhoorn <[email protected]>
  • Loading branch information
3 people authored Mar 5, 2024
1 parent 019ab0b commit 8b013b5
Show file tree
Hide file tree
Showing 25 changed files with 419 additions and 2,567 deletions.
1 change: 0 additions & 1 deletion external/keyring-api
Submodule keyring-api deleted from 1c8eeb
9 changes: 9 additions & 0 deletions snaps/how-to/use-environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ your Snap.
You can use environment variables [on the command line](#use-environment-variables-on-the-command-line)
or [in a `.env` file](#use-environment-variables-in-a-env-file).

:::note
In addition to the environment variables you set, the following environment variables are set by the
Snaps CLI:

- `NODE_ENV="production"`
- `NODE_DEBUG=false`
- `DEBUG=false`
:::

## Use environment variables on the command line

1. Specify environment variables on the command line.
Expand Down
52 changes: 38 additions & 14 deletions snaps/learn/about-snaps/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ description: Learn about the Snap project files.
sidebar_position: 2
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Snaps files

If you look at the directory structure of the Snaps monorepo project generated in the
Expand Down Expand Up @@ -92,29 +95,50 @@ For example, running [`yarn mm-snap build`](../../reference/cli/subcommands.md#b

## Configuration file

The Snap configuration file, `snap.config.ts`, should be placed in the project root directory.
You can override the default values of the [Snaps CLI options](../../reference/cli/options.md) by specifying
them in the `config` object of the configuration file.
The Snap configuration file, `snap.config.js` or `snap.config.ts`, must be placed in the project
root directory.
You can override the default values of the
[Snaps configuration options](../../reference/cli/options.md) by specifying them in the
configuration file.
For example:

```ts
import { resolve } from 'path';
import type { SnapConfig } from '@metamask/snaps-cli';
<Tabs>
<TabItem value="JavaScript">

```javascript title="snap.config.js"
module.exports = {
input: "src/index.js",
output: {
path: "dist",
},
server: {
port: 9000,
},
};
```

</TabItem>
<TabItem value="TypeScript">

```typescript title="snap.config.ts"
import type { SnapConfig } from "@metamask/snaps-cli";

const config: SnapConfig = {
bundler: 'webpack',
input: resolve(__dirname, 'src/index.ts'),
server: {
port: 8080,
},
polyfills: {
buffer: true,
},
input: "src/index.js",
output: {
path: "dist",
},
server: {
port: 9000,
},
};

export default config;
```

</TabItem>
</Tabs>

:::note
You should not publish the configuration file to npm, since it's only used for development and
building.
Expand Down
Loading

0 comments on commit 8b013b5

Please sign in to comment.