Ignore specific Solidity files in hardhat compilation to streamline your development workflow and avoid interruptions, as fast as possiblePhoto by Mohammad Mardani on Unsplash Introduction In Solidity, the hardhat tool is often used for compilation and testing. By default, hardhat will take all .sol files in your project and compile them. However, sometimes you may only want to compile a subset of these files, and ignore others that are in development or not ready for inclusion in the compilation. This can be useful when hardhat may emit errors for files in development, which can interrupt the compilation process for deployment or testing. In this article, we'll show you how to configure hardhat to ignore specific Solidity files during compilation, so you don't have to remove or rename the files temporarily to avoid errors. Setting up hardhat.config.js 1. Importing the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS Task The first step in configuring hardhat to ignore Solidity files is to import the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task from the hardhat/builtin-tasks/task-names module. This task allows you to specify a filter function that will be applied to the list of source paths before they are passed to the Solidity compiler. To import this task, add the following line to your hardhat.config.js file: import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names"; 2. Adding a Subtask to Filter Source Paths Once you have imported the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task, you can add a subtask that sets the action for this task. The action should be a function that takes three arguments: the taskArgs, taskState, and runSuper function. In the function, you can call the runSuper function to get the list of source paths that would normally be passed to the Solidity compiler. Then, you can apply a filter function to this list to remove any paths that you don't want to include in the compilation. For example, you could use a filter like this: // Add a subtask that sets the action for the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS tasksubtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, __, runSuper) => { // Get the list of source paths that would normally be passed to the Solidity compiler const paths = await runSuper(); // Apply a filter function to exclude paths that contain the string "ignore" return paths.filter((p: any) => !p.includes("ignore"));}); This filter will exclude any paths that contain the string “ignore” from the list of source paths passed to the Solidity compiler. You can modify this filter as needed to suit your specific requirements. With the configuration provided in this article, you can add the string “ignore” to the names of any Solidity files that you don’t want to include in the compilation. For example, if you have a file named token.ignore.sol, hardhat will not include it in the compilation process. Conclusion In this article, we showed you how to configure hardhat to ignore specific Solidity files during compilation. By importing the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task and adding a subtask with a custom filter function, you can control which files are included in the compilation process. This can be useful when working on large projects with many Solidity files, and can help you to focus on the files that are relevant to your current development tasks. It can also prevent hardhat from emitting errors for files in development, which can interrupt the compilation process for deployment or testing. Overall, using this method can help you to streamline your Solidity development workflow and improve the efficiency of your hardhat compilation and testing processes. `Want to Connect? You can find me on Twitter/Github/Discord` How to Ignore Solidity Files in Hardhat Compilation was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this storyIgnore specific Solidity files in hardhat compilation to streamline your development workflow and avoid interruptions, as fast as possiblePhoto by Mohammad Mardani on Unsplash Introduction In Solidity, the hardhat tool is often used for compilation and testing. By default, hardhat will take all .sol files in your project and compile them. However, sometimes you may only want to compile a subset of these files, and ignore others that are in development or not ready for inclusion in the compilation. This can be useful when hardhat may emit errors for files in development, which can interrupt the compilation process for deployment or testing. In this article, we'll show you how to configure hardhat to ignore specific Solidity files during compilation, so you don't have to remove or rename the files temporarily to avoid errors. Setting up hardhat.config.js 1. Importing the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS Task The first step in configuring hardhat to ignore Solidity files is to import the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task from the hardhat/builtin-tasks/task-names module. This task allows you to specify a filter function that will be applied to the list of source paths before they are passed to the Solidity compiler. To import this task, add the following line to your hardhat.config.js file: import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names"; 2. Adding a Subtask to Filter Source Paths Once you have imported the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task, you can add a subtask that sets the action for this task. The action should be a function that takes three arguments: the taskArgs, taskState, and runSuper function. In the function, you can call the runSuper function to get the list of source paths that would normally be passed to the Solidity compiler. Then, you can apply a filter function to this list to remove any paths that you don't want to include in the compilation. For example, you could use a filter like this: // Add a subtask that sets the action for the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS tasksubtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, __, runSuper) => { // Get the list of source paths that would normally be passed to the Solidity compiler const paths = await runSuper(); // Apply a filter function to exclude paths that contain the string "ignore" return paths.filter((p: any) => !p.includes("ignore"));}); This filter will exclude any paths that contain the string “ignore” from the list of source paths passed to the Solidity compiler. You can modify this filter as needed to suit your specific requirements. With the configuration provided in this article, you can add the string “ignore” to the names of any Solidity files that you don’t want to include in the compilation. For example, if you have a file named token.ignore.sol, hardhat will not include it in the compilation process. Conclusion In this article, we showed you how to configure hardhat to ignore specific Solidity files during compilation. By importing the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task and adding a subtask with a custom filter function, you can control which files are included in the compilation process. This can be useful when working on large projects with many Solidity files, and can help you to focus on the files that are relevant to your current development tasks. It can also prevent hardhat from emitting errors for files in development, which can interrupt the compilation process for deployment or testing. Overall, using this method can help you to streamline your Solidity development workflow and improve the efficiency of your hardhat compilation and testing processes. `Want to Connect? You can find me on Twitter/Github/Discord` How to Ignore Solidity Files in Hardhat Compilation was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story

How to Ignore Solidity Files in Hardhat Compilation

2025/09/09 21:43

Ignore specific Solidity files in hardhat compilation to streamline your development workflow and avoid interruptions, as fast as possible

Photo by Mohammad Mardani on Unsplash

Introduction

In Solidity, the hardhat tool is often used for compilation and testing. By default, hardhat will take all .sol files in your project and compile them. However, sometimes you may only want to compile a subset of these files, and ignore others that are in development or not ready for inclusion in the compilation. This can be useful when hardhat may emit errors for files in development, which can interrupt the compilation process for deployment or testing. In this article, we'll show you how to configure hardhat to ignore specific Solidity files during compilation, so you don't have to remove or rename the files temporarily to avoid errors.

Setting up hardhat.config.js

1. Importing the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS Task

The first step in configuring hardhat to ignore Solidity files is to import the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task from the hardhat/builtin-tasks/task-names module. This task allows you to specify a filter function that will be applied to the list of source paths before they are passed to the Solidity compiler.

To import this task, add the following line to your hardhat.config.js file:

import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";

2. Adding a Subtask to Filter Source Paths

Once you have imported the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task, you can add a subtask that sets the action for this task. The action should be a function that takes three arguments: the taskArgs, taskState, and runSuper function.

In the function, you can call the runSuper function to get the list of source paths that would normally be passed to the Solidity compiler. Then, you can apply a filter function to this list to remove any paths that you don't want to include in the compilation. For example, you could use a filter like this:

// Add a subtask that sets the action for the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, __, runSuper) => {
// Get the list of source paths that would normally be passed to the Solidity compiler
const paths = await runSuper();

// Apply a filter function to exclude paths that contain the string "ignore"
return paths.filter((p: any) => !p.includes("ignore"));
});

This filter will exclude any paths that contain the string “ignore” from the list of source paths passed to the Solidity compiler. You can modify this filter as needed to suit your specific requirements.

With the configuration provided in this article, you can add the string “ignore” to the names of any Solidity files that you don’t want to include in the compilation. For example, if you have a file named token.ignore.sol, hardhat will not include it in the compilation process.

Conclusion

In this article, we showed you how to configure hardhat to ignore specific Solidity files during compilation. By importing the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task and adding a subtask with a custom filter function, you can control which files are included in the compilation process. This can be useful when working on large projects with many Solidity files, and can help you to focus on the files that are relevant to your current development tasks. It can also prevent hardhat from emitting errors for files in development, which can interrupt the compilation process for deployment or testing. Overall, using this method can help you to streamline your Solidity development workflow and improve the efficiency of your hardhat compilation and testing processes.

`Want to Connect? You can find me on Twitter/Github/Discord`


How to Ignore Solidity Files in Hardhat Compilation was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact [email protected] for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Gold Hits $3,700 as Sprott’s Wong Says Dollar’s Store-of-Value Crown May Slip

Gold Hits $3,700 as Sprott’s Wong Says Dollar’s Store-of-Value Crown May Slip

The post Gold Hits $3,700 as Sprott’s Wong Says Dollar’s Store-of-Value Crown May Slip appeared on BitcoinEthereumNews.com. Gold is strutting its way into record territory, smashing through $3,700 an ounce Wednesday morning, as Sprott Asset Management strategist Paul Wong says the yellow metal may finally snatch the dollar’s most coveted role: store of value. Wong Warns: Fiscal Dominance Puts U.S. Dollar on Notice, Gold on Top Gold prices eased slightly to $3,678.9 […] Source: https://news.bitcoin.com/gold-hits-3700-as-sprotts-wong-says-dollars-store-of-value-crown-may-slip/
Share
BitcoinEthereumNews2025/09/18 00:33
Franklin Templeton CEO Dismisses 50bps Rate Cut Ahead FOMC

Franklin Templeton CEO Dismisses 50bps Rate Cut Ahead FOMC

The post Franklin Templeton CEO Dismisses 50bps Rate Cut Ahead FOMC appeared on BitcoinEthereumNews.com. Franklin Templeton CEO Jenny Johnson has weighed in on whether the Federal Reserve should make a 25 basis points (bps) Fed rate cut or 50 bps cut. This comes ahead of the Fed decision today at today’s FOMC meeting, with the market pricing in a 25 bps cut. Bitcoin and the broader crypto market are currently trading flat ahead of the rate cut decision. Franklin Templeton CEO Weighs In On Potential FOMC Decision In a CNBC interview, Jenny Johnson said that she expects the Fed to make a 25 bps cut today instead of a 50 bps cut. She acknowledged the jobs data, which suggested that the labor market is weakening. However, she noted that this data is backward-looking, indicating that it doesn’t show the current state of the economy. She alluded to the wage growth, which she remarked is an indication of a robust labor market. She added that retail sales are up and that consumers are still spending, despite inflation being sticky at 3%, which makes a case for why the FOMC should opt against a 50-basis-point Fed rate cut. In line with this, the Franklin Templeton CEO said that she would go with a 25 bps rate cut if she were Jerome Powell. She remarked that the Fed still has the October and December FOMC meetings to make further cuts if the incoming data warrants it. Johnson also asserted that the data show a robust economy. However, she noted that there can’t be an argument for no Fed rate cut since Powell already signaled at Jackson Hole that they were likely to lower interest rates at this meeting due to concerns over a weakening labor market. Notably, her comment comes as experts argue for both sides on why the Fed should make a 25 bps cut or…
Share
BitcoinEthereumNews2025/09/18 00:36
[Tambay] Tres niños na bagitos

[Tambay] Tres niños na bagitos

Mga bagong lublób sa malupit na mundo ng Philippine politics ang mga newbies na sina Leviste, Barzaga, at San Fernando, kaya madalas nakakangilo ang kanilang ikinikilos
Share
Rappler2026/01/18 10:00