Change your config globally

You might not like the extra folder required to configure Prisma Util. This guide will provide a quick and easy way of changing the root directory for the configuration file.

When using Prisma Util, you are forced to use a folder setup. By folder setup, we mean that you have to use a different folder like prisma-util that holds your configuration files. During this guide, we're going to get rid of the prisma-util folder and instead use the pre-v2.0.0 way of configuring Prisma Util (using the prisma-util.config.mjs file).

During this guide, we're going to use the following folder structure:

File Structure
change-config-path (Project Root)
    @node_modules
    prisma-util
        config.mjs
    .env
    package.json

So, let's get started.

1. Change the root directory

First of all, let's change the root directory from prisma-util to change-config-path. To do this, we're going to use the newly introduced configure command.

Open your terminal and type the following commands:

Terminal
npx prisma-util configure root .

This command will set the root folder to the project root. We can now move the config.mjs file to change-config-path and get rid of the initial folder. Our file structure should look like this now:

File Structure
change-config-path (Project Root)
    @node_modules
    .env
    config.mjs
    package.json

2. Change the configuration file name

Using config.mjs is pretty generic and we'd rather have something more descriptive such as prisma-util.config.mjs. To do this, let's rename our configuration file to the new path, and bring our file structure to this state:

File Structure
change-config-path (Project Root)
    @node_modules
    .env
    prisma-util.config.mjs
    package.json

Now, we just have to tell Prisma Util that we no longer want to use config.mjs as our configuration file. To do this, we can use the configure command from earlier like this:

Terminal
npx prisma-util configure config prisma-util.config.mjs

And we're done!

Wrapping Up

This feature has been requested by developers using Prisma Util, so we found a way of introducing it without creating breaking changes into the package.

Last updated