'hardhat-deploy: how to specify contracts organized in folder

As title specified, I would to know if can you deploy contracts organized in folders. In HardhatConfig you can specify only root folder but no others. My Hardhat.paths folder is "contracts" and it is so composed:

contracts | folder1 | Contract1.sol ... etc

I tried to deploy Contract1.sol but it returned Error: cannot find artifact "folder1/Contract1.sol"

hardhat.config.js

...
paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts"
  },
...

01_deploy.js

module.exports = async ({
    getNamedAccounts,
    deployments,
  }) => {
    const contractName = "folder1/Contract1";

    var networkId = network.name
    const {deploy} = deployments;
    const {deployer} = await getNamedAccounts()
    const contract = await deploy(contractName, {
      from: deployer,
      gasLimit: 4000000,
      log: true
    });
  };


Solution 1:[1]

Hardhat compiles all contracts in the contracts directory at any nesting level, so you don't need to specify directory in your contractName argument for deploy function

const contractName = "Contract1";

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vasylOk