<?xml version="1.0" encoding="utf-8"?>
<!--Generated by DFIN XBRL Instance Document - http://www.dfinsolutions.com/ - Version R3.0 - on 04-August-2022 [07:25:31] {AM}-->
<linkbase xmlns="http://www.xbrl.org/2003/linkbase" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd" xmlns:xbrldt="http://xbrl.org/2005/xbrldt">
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CondensedConsolidatedStatementsOfChangesInStockholdersEquity" roleURI="http://www.trex.com/role/CondensedConsolidatedStatementsOfChangesInStockholdersEquity" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockBasedCompensationTables" roleURI="http://www.trex.com/role/StockBasedCompensationTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#GoodwillAndOtherIntangibleAssetsNetAdditionalInformationDetail" roleURI="http://www.trex.com/role/GoodwillAndOtherIntangibleAssetsNetAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#DebtAdditionalInformationDetail" roleURI="http://www.trex.com/role/DebtAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#LeasesAdditionalInformationDetail" roleURI="http://www.trex.com/role/LeasesAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#LeasesSupplementalCashFlowInformationToOperatingLeasesDetails" roleURI="http://www.trex.com/role/LeasesSupplementalCashFlowInformationToOperatingLeasesDetails" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#LeasesMaturitiesOfOperatingLeaseLiabilitiesDetails" roleURI="http://www.trex.com/role/LeasesMaturitiesOfOperatingLeaseLiabilitiesDetails" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockholdersEquityAdditionalInformationDetail" roleURI="http://www.trex.com/role/StockholdersEquityAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockholdersEquityComputationOfBasicAndDilutedEarningsPerShareDetail" roleURI="http://www.trex.com/role/StockholdersEquityComputationOfBasicAndDilutedEarningsPerShareDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockholdersEquityAntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareDetail" roleURI="http://www.trex.com/role/StockholdersEquityAntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#RevenueFromContractsWithCustomersSummaryOfDisaggregatedNetSalesDetail" roleURI="http://www.trex.com/role/RevenueFromContractsWithCustomersSummaryOfDisaggregatedNetSalesDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockBasedCompensationAdditionalInformationDetail" roleURI="http://www.trex.com/role/StockBasedCompensationAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockBasedCompensationSummaryOfStockBasedCompensationGrantsDetail" roleURI="http://www.trex.com/role/StockBasedCompensationSummaryOfStockBasedCompensationGrantsDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockBasedCompensationSummaryOfAssumptionsUsedToEstimateFairValueOfEachSarDetail" roleURI="http://www.trex.com/role/StockBasedCompensationSummaryOfAssumptionsUsedToEstimateFairValueOfEachSarDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockBasedCompensationSummaryOfStockBasedCompensationExpensesDetail" roleURI="http://www.trex.com/role/StockBasedCompensationSummaryOfStockBasedCompensationExpensesDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#IncomeTaxesAdditionalInformationDetail" roleURI="http://www.trex.com/role/IncomeTaxesAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#SegmentInformationAdditionalInformationDetail" roleURI="http://www.trex.com/role/SegmentInformationAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#SegmentInformationDetailsOfSegmentInformationDetail" roleURI="http://www.trex.com/role/SegmentInformationDetailsOfSegmentInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#SegmentInformationScheduleOfReconciliationOfNetIncomeToEbitdaDetail" roleURI="http://www.trex.com/role/SegmentInformationScheduleOfReconciliationOfNetIncomeToEbitdaDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CommitmentsAndContingenciesAdditionalInformationDetail" roleURI="http://www.trex.com/role/CommitmentsAndContingenciesAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CommitmentsAndContingenciesSummaryOfReconciliationOfCompanysResidentialProductWarrantyReserveDetail" roleURI="http://www.trex.com/role/CommitmentsAndContingenciesSummaryOfReconciliationOfCompanysResidentialProductWarrantyReserveDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CondensedConsolidatedStatementsOfComprehensiveIncome" roleURI="http://www.trex.com/role/CondensedConsolidatedStatementsOfComprehensiveIncome" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CondensedConsolidatedBalanceSheetsParenthetical" roleURI="http://www.trex.com/role/CondensedConsolidatedBalanceSheetsParenthetical" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CondensedConsolidatedStatementsOfCashFlows" roleURI="http://www.trex.com/role/CondensedConsolidatedStatementsOfCashFlows" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#BusinessAndOrganizationAdditionalInformationDetail" roleURI="http://www.trex.com/role/BusinessAndOrganizationAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#InventoriesSummaryOfInventoriesDetail" roleURI="http://www.trex.com/role/InventoriesSummaryOfInventoriesDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#InventoriesAdditionalInformationDetail" roleURI="http://www.trex.com/role/InventoriesAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#PrepaidExpensesAndOtherAssetsSummaryOfPrepaidExpensesAndOtherAssetsDetail" roleURI="http://www.trex.com/role/PrepaidExpensesAndOtherAssetsSummaryOfPrepaidExpensesAndOtherAssetsDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#AccruedExpensesAndOtherLiabilitiesSummaryOfAccruedExpensesAndOtherLiabilitiesDetail" roleURI="http://www.trex.com/role/AccruedExpensesAndOtherLiabilitiesSummaryOfAccruedExpensesAndOtherLiabilitiesDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#RevenueFromContractsWithCustomersAdditionalInformationDetail" roleURI="http://www.trex.com/role/RevenueFromContractsWithCustomersAdditionalInformationDetail" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#Inventories" roleURI="http://www.trex.com/role/Inventories" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#InventoriesTables" roleURI="http://www.trex.com/role/InventoriesTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#PrepaidExpensesAndOtherAssets" roleURI="http://www.trex.com/role/PrepaidExpensesAndOtherAssets" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#PrepaidExpensesAndOtherAssetsTables" roleURI="http://www.trex.com/role/PrepaidExpensesAndOtherAssetsTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#GoodwillAndOtherIntangibleAssetsNet" roleURI="http://www.trex.com/role/GoodwillAndOtherIntangibleAssetsNet" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#AccruedExpensesAndOtherLiabilities" roleURI="http://www.trex.com/role/AccruedExpensesAndOtherLiabilities" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#AccruedExpensesAndOtherLiabilitiesTables" roleURI="http://www.trex.com/role/AccruedExpensesAndOtherLiabilitiesTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#Debt" roleURI="http://www.trex.com/role/Debt" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#FinancialInstruments" roleURI="http://www.trex.com/role/FinancialInstruments" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockholdersEquity" roleURI="http://www.trex.com/role/StockholdersEquity" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockholdersEquityTables" roleURI="http://www.trex.com/role/StockholdersEquityTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#RevenueFromContractsWithCustomers" roleURI="http://www.trex.com/role/RevenueFromContractsWithCustomers" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#RevenueFromContractsWithCustomersTables" roleURI="http://www.trex.com/role/RevenueFromContractsWithCustomersTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#StockBasedCompensation" roleURI="http://www.trex.com/role/StockBasedCompensation" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#BusinessAndOrganization" roleURI="http://www.trex.com/role/BusinessAndOrganization" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#Leases" roleURI="http://www.trex.com/role/Leases" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#IncomeTaxes" roleURI="http://www.trex.com/role/IncomeTaxes" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#SegmentInformation" roleURI="http://www.trex.com/role/SegmentInformation" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#SegmentInformationTables" roleURI="http://www.trex.com/role/SegmentInformationTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#Seasonality" roleURI="http://www.trex.com/role/Seasonality" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CommitmentsAndContingencies" roleURI="http://www.trex.com/role/CommitmentsAndContingencies" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CommitmentsAndContingenciesTables" roleURI="http://www.trex.com/role/CommitmentsAndContingenciesTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#LeasesTables" roleURI="http://www.trex.com/role/LeasesTables" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CondensedConsolidatedBalanceSheets" roleURI="http://www.trex.com/role/CondensedConsolidatedBalanceSheets" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#SummaryOfSignificantAccountingPoliciesPolicies" roleURI="http://www.trex.com/role/SummaryOfSignificantAccountingPoliciesPolicies" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#BasisOfPresentation" roleURI="http://www.trex.com/role/BasisOfPresentation" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#RecentlyAdoptedAccountingStandards" roleURI="http://www.trex.com/role/RecentlyAdoptedAccountingStandards" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#CoverPage" roleURI="http://www.trex.com/role/CoverPage" />
<roleRef xlink:type="simple" xlink:href="trex-20220630.xsd#NewAccountingStandardsNotYetAdopted" roleURI="http://www.trex.com/role/NewAccountingStandardsNotYetAdopted" />
<arcroleRef arcroleURI="http://xbrl.org/int/dim/arcrole/all" xlink:type="simple" xlink:href="http://www.xbrl.org/2005/xbrldt-2005.xsd#all" />
<arcroleRef arcroleURI="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:type="simple" xlink:href="http://www.xbrl.org/2005/xbrldt-2005.xsd#dimension-default" />
<arcroleRef arcroleURI="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:type="simple" xlink:href="http://www.xbrl.org/2005/xbrldt-2005.xsd#dimension-domain" />
<arcroleRef arcroleURI="http://xbrl.org/int/dim/arcrole/domain-member" xlink:type="simple" xlink:href="http://www.xbrl.org/2005/xbrldt-2005.xsd#domain-member" />
<arcroleRef arcroleURI="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:type="simple" xlink:href="http://www.xbrl.org/2005/xbrldt-2005.xsd#hypercube-dimension" />
<arcroleRef arcroleURI="http://xbrl.org/int/dim/arcrole/notAll" xlink:type="simple" xlink:href="http://www.xbrl.org/2005/xbrldt-2005.xsd#notAll" />
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/CondensedConsolidatedStatementsOfChangesInStockholdersEquity">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementLineItems" xlink:label="loc_us-gaap_StatementLineItems_84" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SharesIssued" xlink:label="loc_us-gaap_SharesIssued_91" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_SharesIssued_91" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TreasuryStockSharesAcquired" xlink:label="loc_us-gaap_TreasuryStockSharesAcquired_100" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_TreasuryStockSharesAcquired_100" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockRepurchasedDuringPeriodValue" xlink:label="loc_us-gaap_StockRepurchasedDuringPeriodValue_99" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_StockRepurchasedDuringPeriodValue_99" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_NetIncomeLoss" xlink:label="loc_us-gaap_NetIncomeLoss_92" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_NetIncomeLoss_92" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockIssuedDuringPeriodValueShareBasedCompensationGross" xlink:label="loc_us-gaap_StockIssuedDuringPeriodValueShareBasedCompensationGross_97" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_StockIssuedDuringPeriodValueShareBasedCompensationGross_97" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockholdersEquity" xlink:label="loc_us-gaap_StockholdersEquity_90" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_StockholdersEquity_90" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockIssuedDuringPeriodSharesShareBasedCompensation" xlink:label="loc_us-gaap_StockIssuedDuringPeriodSharesShareBasedCompensation_94" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_StockIssuedDuringPeriodSharesShareBasedCompensation_94" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockIssuedDuringPeriodSharesShareBasedCompensationGross" xlink:label="loc_us-gaap_StockIssuedDuringPeriodSharesShareBasedCompensationGross_98" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_StockIssuedDuringPeriodSharesShareBasedCompensationGross_98" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AdjustmentsRelatedToTaxWithholdingForShareBasedCompensation" xlink:label="loc_us-gaap_AdjustmentsRelatedToTaxWithholdingForShareBasedCompensation_95" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_AdjustmentsRelatedToTaxWithholdingForShareBasedCompensation_95" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockIssuedDuringPeriodValueShareBasedCompensation" xlink:label="loc_us-gaap_StockIssuedDuringPeriodValueShareBasedCompensation_93" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_StockIssuedDuringPeriodValueShareBasedCompensation_93" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SharesPaidForTaxWithholdingForShareBasedCompensation" xlink:label="loc_us-gaap_SharesPaidForTaxWithholdingForShareBasedCompensation_96" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_SharesPaidForTaxWithholdingForShareBasedCompensation_96" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementTable" xlink:label="loc_us-gaap_StatementTable_85" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_StatementLineItems_84" xlink:to="loc_us-gaap_StatementTable_85" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementEquityComponentsAxis" xlink:label="loc_us-gaap_StatementEquityComponentsAxis_83" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_StatementTable_85" xlink:to="loc_us-gaap_StatementEquityComponentsAxis_83" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EquityComponentDomain" xlink:label="loc_us-gaap_EquityComponentDomain_82" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_StatementEquityComponentsAxis_83" xlink:to="loc_us-gaap_EquityComponentDomain_82" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EquityComponentDomain" xlink:label="loc_us-gaap_EquityComponentDomain_82_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_StatementEquityComponentsAxis_83" xlink:to="loc_us-gaap_EquityComponentDomain_82_default" use="optional" order="15" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TreasuryStockMember" xlink:label="loc_us-gaap_TreasuryStockMember_89" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityComponentDomain_82" xlink:to="loc_us-gaap_TreasuryStockMember_89" use="optional" order="16" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_RetainedEarningsMember" xlink:label="loc_us-gaap_RetainedEarningsMember_88" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityComponentDomain_82" xlink:to="loc_us-gaap_RetainedEarningsMember_88" use="optional" order="17" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AdditionalPaidInCapitalMember" xlink:label="loc_us-gaap_AdditionalPaidInCapitalMember_87" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityComponentDomain_82" xlink:to="loc_us-gaap_AdditionalPaidInCapitalMember_87" use="optional" order="18" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CommonStockMember" xlink:label="loc_us-gaap_CommonStockMember_86" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityComponentDomain_82" xlink:to="loc_us-gaap_CommonStockMember_86" use="optional" order="19" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockBasedCompensationTables">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementLineItems" xlink:label="loc_us-gaap_StatementLineItems_839" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementTable" xlink:label="loc_us-gaap_StatementTable_840" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_StatementLineItems_839" xlink:to="loc_us-gaap_StatementTable_840" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AwardTypeAxis" xlink:label="loc_us-gaap_AwardTypeAxis_837" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_StatementTable_840" xlink:to="loc_us-gaap_AwardTypeAxis_837" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_838" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AwardTypeAxis_837" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_838" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_838_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AwardTypeAxis_837" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_838_default" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfShareBasedPaymentAwardStockOptionsValuationAssumptionsTableTextBlock" xlink:label="loc_us-gaap_ScheduleOfShareBasedPaymentAwardStockOptionsValuationAssumptionsTableTextBlock_845" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_839" xlink:to="loc_us-gaap_ScheduleOfShareBasedPaymentAwardStockOptionsValuationAssumptionsTableTextBlock_845" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardOptionsGrantsInPeriodWeightedAverageGrantDateFairValueTableTextBlock" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardOptionsGrantsInPeriodWeightedAverageGrantDateFairValueTableTextBlock_378535" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_839" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardOptionsGrantsInPeriodWeightedAverageGrantDateFairValueTableTextBlock_378535" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfCompensationCostForShareBasedPaymentArrangementsAllocationOfShareBasedCompensationCostsByPlanTableTextBlock" xlink:label="loc_us-gaap_ScheduleOfCompensationCostForShareBasedPaymentArrangementsAllocationOfShareBasedCompensationCostsByPlanTableTextBlock_843" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_839" xlink:to="loc_us-gaap_ScheduleOfCompensationCostForShareBasedPaymentArrangementsAllocationOfShareBasedCompensationCostsByPlanTableTextBlock_843" use="optional" order="7" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/GoodwillAndOtherIntangibleAssetsNetAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_GoodwillLineItems" xlink:label="loc_us-gaap_GoodwillLineItems_280" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FiniteLivedIntangibleAssetsAccumulatedAmortization" xlink:label="loc_us-gaap_FiniteLivedIntangibleAssetsAccumulatedAmortization_561623" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_GoodwillLineItems_280" xlink:to="loc_us-gaap_FiniteLivedIntangibleAssetsAccumulatedAmortization_561623" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FiniteLivedIntangibleAssetUsefulLife" xlink:label="loc_us-gaap_FiniteLivedIntangibleAssetUsefulLife_288" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_GoodwillLineItems_280" xlink:to="loc_us-gaap_FiniteLivedIntangibleAssetUsefulLife_288" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AmortizationOfIntangibleAssets" xlink:label="loc_us-gaap_AmortizationOfIntangibleAssets_290" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_GoodwillLineItems_280" xlink:to="loc_us-gaap_AmortizationOfIntangibleAssets_290" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfGoodwillTable" xlink:label="loc_us-gaap_ScheduleOfGoodwillTable_283" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_GoodwillLineItems_280" xlink:to="loc_us-gaap_ScheduleOfGoodwillTable_283" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IndefiniteLivedIntangibleAssetsByMajorClassAxis" xlink:label="loc_us-gaap_IndefiniteLivedIntangibleAssetsByMajorClassAxis_281" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfGoodwillTable_283" xlink:to="loc_us-gaap_IndefiniteLivedIntangibleAssetsByMajorClassAxis_281" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IndefiniteLivedIntangibleAssetsMajorClassNameDomain" xlink:label="loc_us-gaap_IndefiniteLivedIntangibleAssetsMajorClassNameDomain_282" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_IndefiniteLivedIntangibleAssetsByMajorClassAxis_281" xlink:to="loc_us-gaap_IndefiniteLivedIntangibleAssetsMajorClassNameDomain_282" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IndefiniteLivedIntangibleAssetsMajorClassNameDomain" xlink:label="loc_us-gaap_IndefiniteLivedIntangibleAssetsMajorClassNameDomain_282_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_IndefiniteLivedIntangibleAssetsByMajorClassAxis_281" xlink:to="loc_us-gaap_IndefiniteLivedIntangibleAssetsMajorClassNameDomain_282_default" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentAxis" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_276" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfGoodwillTable_283" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_276" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_277" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_276" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_277" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_277_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_276" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_277_default" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ResidentialPortfolioSegmentMember" xlink:label="loc_us-gaap_ResidentialPortfolioSegmentMember_285" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_277" xlink:to="loc_us-gaap_ResidentialPortfolioSegmentMember_285" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FiniteLivedIntangibleAssetsByMajorClassAxis" xlink:label="loc_us-gaap_FiniteLivedIntangibleAssetsByMajorClassAxis_278" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfGoodwillTable_283" xlink:to="loc_us-gaap_FiniteLivedIntangibleAssetsByMajorClassAxis_278" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FiniteLivedIntangibleAssetsMajorClassNameDomain" xlink:label="loc_us-gaap_FiniteLivedIntangibleAssetsMajorClassNameDomain_279" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_FiniteLivedIntangibleAssetsByMajorClassAxis_278" xlink:to="loc_us-gaap_FiniteLivedIntangibleAssetsMajorClassNameDomain_279" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FiniteLivedIntangibleAssetsMajorClassNameDomain" xlink:label="loc_us-gaap_FiniteLivedIntangibleAssetsMajorClassNameDomain_279_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_FiniteLivedIntangibleAssetsByMajorClassAxis_278" xlink:to="loc_us-gaap_FiniteLivedIntangibleAssetsMajorClassNameDomain_279_default" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_InternetDomainNamesMember" xlink:label="loc_us-gaap_InternetDomainNamesMember_286" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FiniteLivedIntangibleAssetsMajorClassNameDomain_279" xlink:to="loc_us-gaap_InternetDomainNamesMember_286" use="optional" order="15" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_Goodwill" xlink:label="loc_us-gaap_Goodwill_287" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_GoodwillLineItems_280" xlink:to="loc_us-gaap_Goodwill_287" use="optional" order="16" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IntangibleAssetsGrossExcludingGoodwill" xlink:label="loc_us-gaap_IntangibleAssetsGrossExcludingGoodwill_561618" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_GoodwillLineItems_280" xlink:to="loc_us-gaap_IntangibleAssetsGrossExcludingGoodwill_561618" use="optional" order="17" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/DebtAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityLineItems" xlink:label="loc_us-gaap_LineOfCreditFacilityLineItems_348" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityExpirationDate1" xlink:label="loc_us-gaap_LineOfCreditFacilityExpirationDate1_364" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_us-gaap_LineOfCreditFacilityExpirationDate1_364" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DebtInstrumentBasisSpreadOnVariableRate1" xlink:label="loc_us-gaap_DebtInstrumentBasisSpreadOnVariableRate1_365" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_us-gaap_DebtInstrumentBasisSpreadOnVariableRate1_365" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityMaximumBorrowingCapacity" xlink:label="loc_us-gaap_LineOfCreditFacilityMaximumBorrowingCapacity_363" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_us-gaap_LineOfCreditFacilityMaximumBorrowingCapacity_363" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LinesOfCreditCurrent" xlink:label="loc_us-gaap_LinesOfCreditCurrent_378350" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_us-gaap_LinesOfCreditCurrent_378350" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_LineOfCreditFacilityAdditionalBorrowingCapacity" xlink:label="loc_trex_LineOfCreditFacilityAdditionalBorrowingCapacity_802770" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_trex_LineOfCreditFacilityAdditionalBorrowingCapacity_802770" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityRemainingBorrowingCapacity" xlink:label="loc_us-gaap_LineOfCreditFacilityRemainingBorrowingCapacity_362" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_us-gaap_LineOfCreditFacilityRemainingBorrowingCapacity_362" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityTable" xlink:label="loc_us-gaap_LineOfCreditFacilityTable_349" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_us-gaap_LineOfCreditFacilityTable_349" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DebtInstrumentAxis" xlink:label="loc_us-gaap_DebtInstrumentAxis_346" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_LineOfCreditFacilityTable_349" xlink:to="loc_us-gaap_DebtInstrumentAxis_346" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DebtInstrumentNameDomain" xlink:label="loc_us-gaap_DebtInstrumentNameDomain_347" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_DebtInstrumentAxis_346" xlink:to="loc_us-gaap_DebtInstrumentNameDomain_347" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DebtInstrumentNameDomain" xlink:label="loc_us-gaap_DebtInstrumentNameDomain_347_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_DebtInstrumentAxis_346" xlink:to="loc_us-gaap_DebtInstrumentNameDomain_347_default" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_FourthamendedandrestatedcreditagreementMember" xlink:label="loc_trex_FourthamendedandrestatedcreditagreementMember_561678" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_DebtInstrumentNameDomain_347" xlink:to="loc_trex_FourthamendedandrestatedcreditagreementMember_561678" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_VariableRateAxis" xlink:label="loc_us-gaap_VariableRateAxis_352" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_LineOfCreditFacilityTable_349" xlink:to="loc_us-gaap_VariableRateAxis_352" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_VariableRateDomain" xlink:label="loc_us-gaap_VariableRateDomain_353" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_VariableRateAxis_352" xlink:to="loc_us-gaap_VariableRateDomain_353" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_VariableRateDomain" xlink:label="loc_us-gaap_VariableRateDomain_353_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_VariableRateAxis_352" xlink:to="loc_us-gaap_VariableRateDomain_353_default" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_BaseRateMember" xlink:label="loc_us-gaap_BaseRateMember_1562897" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_VariableRateDomain_353" xlink:to="loc_us-gaap_BaseRateMember_1562897" use="optional" order="15" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SecuredOvernightFinancingRateSofrOvernightIndexSwapRateMember" xlink:label="loc_us-gaap_SecuredOvernightFinancingRateSofrOvernightIndexSwapRateMember_1562898" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_VariableRateDomain_353" xlink:to="loc_us-gaap_SecuredOvernightFinancingRateSofrOvernightIndexSwapRateMember_1562898" use="optional" order="16" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityAxis" xlink:label="loc_us-gaap_LineOfCreditFacilityAxis_802771" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_LineOfCreditFacilityTable_349" xlink:to="loc_us-gaap_LineOfCreditFacilityAxis_802771" use="optional" order="17" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityLenderDomain" xlink:label="loc_us-gaap_LineOfCreditFacilityLenderDomain_802772" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_LineOfCreditFacilityAxis_802771" xlink:to="loc_us-gaap_LineOfCreditFacilityLenderDomain_802772" use="optional" order="18" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LineOfCreditFacilityLenderDomain" xlink:label="loc_us-gaap_LineOfCreditFacilityLenderDomain_802772_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_LineOfCreditFacilityAxis_802771" xlink:to="loc_us-gaap_LineOfCreditFacilityLenderDomain_802772_default" use="optional" order="19" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CreditFacilityAxis" xlink:label="loc_us-gaap_CreditFacilityAxis_344" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_LineOfCreditFacilityTable_349" xlink:to="loc_us-gaap_CreditFacilityAxis_344" use="optional" order="20" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CreditFacilityDomain" xlink:label="loc_us-gaap_CreditFacilityDomain_345" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_CreditFacilityAxis_344" xlink:to="loc_us-gaap_CreditFacilityDomain_345" use="optional" order="21" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CreditFacilityDomain" xlink:label="loc_us-gaap_CreditFacilityDomain_345_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_CreditFacilityAxis_344" xlink:to="loc_us-gaap_CreditFacilityDomain_345_default" use="optional" order="22" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_RevolverLoansPortionEffectiveOneJanuaryThroughThirtyJuneMember" xlink:label="loc_trex_RevolverLoansPortionEffectiveOneJanuaryThroughThirtyJuneMember_354" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_CreditFacilityDomain_345" xlink:to="loc_trex_RevolverLoansPortionEffectiveOneJanuaryThroughThirtyJuneMember_354" use="optional" order="23" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_RevolverLoansPortionEffectiveOneJulyThroughThirtyFirstDecemberMember" xlink:label="loc_trex_RevolverLoansPortionEffectiveOneJulyThroughThirtyFirstDecemberMember_355" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_CreditFacilityDomain_345" xlink:to="loc_trex_RevolverLoansPortionEffectiveOneJulyThroughThirtyFirstDecemberMember_355" use="optional" order="24" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_RevolvingCreditFacilityMember" xlink:label="loc_us-gaap_RevolvingCreditFacilityMember_356" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_CreditFacilityDomain_345" xlink:to="loc_us-gaap_RevolvingCreditFacilityMember_356" use="optional" order="25" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_AgreementAxis" xlink:label="loc_trex_AgreementAxis_1562878" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_LineOfCreditFacilityTable_349" xlink:to="loc_trex_AgreementAxis_1562878" use="optional" order="26" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_AgreementDomain" xlink:label="loc_trex_AgreementDomain_1562880" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_trex_AgreementAxis_1562878" xlink:to="loc_trex_AgreementDomain_1562880" use="optional" order="27" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_AgreementDomain" xlink:label="loc_trex_AgreementDomain_1562880_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_trex_AgreementAxis_1562878" xlink:to="loc_trex_AgreementDomain_1562880_default" use="optional" order="28" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_FifthAmendmentAndRestatedAgreementMember" xlink:label="loc_trex_FifthAmendmentAndRestatedAgreementMember_1562881" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_AgreementDomain_1562880" xlink:to="loc_trex_FifthAmendmentAndRestatedAgreementMember_1562881" use="optional" order="29" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_CreditFacilityOneAxis" xlink:label="loc_trex_CreditFacilityOneAxis_1562885" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_LineOfCreditFacilityTable_349" xlink:to="loc_trex_CreditFacilityOneAxis_1562885" use="optional" order="30" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_CreditFacilityOneDomain" xlink:label="loc_trex_CreditFacilityOneDomain_1562886" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_trex_CreditFacilityOneAxis_1562885" xlink:to="loc_trex_CreditFacilityOneDomain_1562886" use="optional" order="31" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_CreditFacilityOneDomain" xlink:label="loc_trex_CreditFacilityOneDomain_1562886_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_trex_CreditFacilityOneAxis_1562885" xlink:to="loc_trex_CreditFacilityOneDomain_1562886_default" use="optional" order="32" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LetterOfCreditMember" xlink:label="loc_us-gaap_LetterOfCreditMember_1562887" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_CreditFacilityOneDomain_1562886" xlink:to="loc_us-gaap_LetterOfCreditMember_1562887" use="optional" order="33" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_SwinglineLetterOfCreditMember" xlink:label="loc_trex_SwinglineLetterOfCreditMember_1562889" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_CreditFacilityOneDomain_1562886" xlink:to="loc_trex_SwinglineLetterOfCreditMember_1562889" use="optional" order="34" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_NumberOfBusinessDaysWithinWhichLenderMayRaiseObjectionsToAmendment" xlink:label="loc_trex_NumberOfBusinessDaysWithinWhichLenderMayRaiseObjectionsToAmendment_1562877" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_trex_NumberOfBusinessDaysWithinWhichLenderMayRaiseObjectionsToAmendment_1562877" use="optional" order="35" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DebtInstrumentDescriptionOfVariableRateBasis" xlink:label="loc_us-gaap_DebtInstrumentDescriptionOfVariableRateBasis_1563943" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_LineOfCreditFacilityLineItems_348" xlink:to="loc_us-gaap_DebtInstrumentDescriptionOfVariableRateBasis_1563943" use="optional" order="36" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/LeasesAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementLineItems" xlink:label="loc_us-gaap_StatementLineItems_378483" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseCost" xlink:label="loc_us-gaap_OperatingLeaseCost_378456" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378483" xlink:to="loc_us-gaap_OperatingLeaseCost_378456" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseWeightedAverageRemainingLeaseTerm1" xlink:label="loc_us-gaap_OperatingLeaseWeightedAverageRemainingLeaseTerm1_378611" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378483" xlink:to="loc_us-gaap_OperatingLeaseWeightedAverageRemainingLeaseTerm1_378611" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementTable" xlink:label="loc_us-gaap_StatementTable_378480" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_StatementLineItems_378483" xlink:to="loc_us-gaap_StatementTable_378480" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementClassOfStockAxis" xlink:label="loc_us-gaap_StatementClassOfStockAxis_378481" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_StatementTable_378480" xlink:to="loc_us-gaap_StatementClassOfStockAxis_378481" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ClassOfStockDomain" xlink:label="loc_us-gaap_ClassOfStockDomain_378482" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_StatementClassOfStockAxis_378481" xlink:to="loc_us-gaap_ClassOfStockDomain_378482" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ClassOfStockDomain" xlink:label="loc_us-gaap_ClassOfStockDomain_378482_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_StatementClassOfStockAxis_378481" xlink:to="loc_us-gaap_ClassOfStockDomain_378482_default" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeAxis" xlink:label="loc_srt_RangeAxis_378484" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_StatementTable_378480" xlink:to="loc_srt_RangeAxis_378484" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeMember" xlink:label="loc_srt_RangeMember_378485" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_srt_RangeAxis_378484" xlink:to="loc_srt_RangeMember_378485" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeMember" xlink:label="loc_srt_RangeMember_378485_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_srt_RangeAxis_378484" xlink:to="loc_srt_RangeMember_378485_default" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_MinimumMember" xlink:label="loc_srt_MinimumMember_378487" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_srt_RangeMember_378485" xlink:to="loc_srt_MinimumMember_378487" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_MaximumMember" xlink:label="loc_srt_MaximumMember_378486" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_srt_RangeMember_378485" xlink:to="loc_srt_MaximumMember_378486" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseWeightedAverageDiscountRatePercent" xlink:label="loc_us-gaap_OperatingLeaseWeightedAverageDiscountRatePercent_378455" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378483" xlink:to="loc_us-gaap_OperatingLeaseWeightedAverageDiscountRatePercent_378455" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LessorOperatingLeaseTermOfContract" xlink:label="loc_us-gaap_LessorOperatingLeaseTermOfContract_378457" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378483" xlink:to="loc_us-gaap_LessorOperatingLeaseTermOfContract_378457" use="optional" order="13" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/LeasesSupplementalCashFlowInformationToOperatingLeasesDetails">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementLineItems" xlink:label="loc_us-gaap_StatementLineItems_378383" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseLiability" xlink:label="loc_us-gaap_OperatingLeaseLiability_378424" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378383" xlink:to="loc_us-gaap_OperatingLeaseLiability_378424" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_SupplementalBalanceSheetInformationAbstract" xlink:label="loc_trex_SupplementalBalanceSheetInformationAbstract_378420" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378383" xlink:to="loc_trex_SupplementalBalanceSheetInformationAbstract_378420" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseRightOfUseAsset" xlink:label="loc_us-gaap_OperatingLeaseRightOfUseAsset_378416" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_SupplementalBalanceSheetInformationAbstract_378420" xlink:to="loc_us-gaap_OperatingLeaseRightOfUseAsset_378416" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementTable" xlink:label="loc_us-gaap_StatementTable_378380" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_StatementLineItems_378383" xlink:to="loc_us-gaap_StatementTable_378380" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementClassOfStockAxis" xlink:label="loc_us-gaap_StatementClassOfStockAxis_563044" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_StatementTable_378380" xlink:to="loc_us-gaap_StatementClassOfStockAxis_563044" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ClassOfStockDomain" xlink:label="loc_us-gaap_ClassOfStockDomain_563045" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_StatementClassOfStockAxis_563044" xlink:to="loc_us-gaap_ClassOfStockDomain_563045" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ClassOfStockDomain" xlink:label="loc_us-gaap_ClassOfStockDomain_563045_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_StatementClassOfStockAxis_563044" xlink:to="loc_us-gaap_ClassOfStockDomain_563045_default" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AssetsAndLiabilitiesLesseeAbstract" xlink:label="loc_us-gaap_AssetsAndLiabilitiesLesseeAbstract_378406" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378383" xlink:to="loc_us-gaap_AssetsAndLiabilitiesLesseeAbstract_378406" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseLiabilityNoncurrent" xlink:label="loc_us-gaap_OperatingLeaseLiabilityNoncurrent_378423" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_AssetsAndLiabilitiesLesseeAbstract_378406" xlink:to="loc_us-gaap_OperatingLeaseLiabilityNoncurrent_378423" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_LesseeOperatingLeasesAccruedExpensesAndOtherCurrentLiabilities" xlink:label="loc_trex_LesseeOperatingLeasesAccruedExpensesAndOtherCurrentLiabilities_378422" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_AssetsAndLiabilitiesLesseeAbstract_378406" xlink:to="loc_trex_LesseeOperatingLeasesAccruedExpensesAndOtherCurrentLiabilities_378422" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CashFlowOperatingActivitiesLesseeAbstract" xlink:label="loc_us-gaap_CashFlowOperatingActivitiesLesseeAbstract_378384" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378383" xlink:to="loc_us-gaap_CashFlowOperatingActivitiesLesseeAbstract_378384" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_RightOfUseAssetObtainedInExchangeForOperatingLeaseLiability" xlink:label="loc_us-gaap_RightOfUseAssetObtainedInExchangeForOperatingLeaseLiability_378414" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_CashFlowOperatingActivitiesLesseeAbstract_378384" xlink:to="loc_us-gaap_RightOfUseAssetObtainedInExchangeForOperatingLeaseLiability_378414" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeasePayments" xlink:label="loc_us-gaap_OperatingLeasePayments_378411" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_CashFlowOperatingActivitiesLesseeAbstract_378384" xlink:to="loc_us-gaap_OperatingLeasePayments_378411" use="optional" order="13" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/LeasesMaturitiesOfOperatingLeaseLiabilitiesDetails">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementLineItems" xlink:label="loc_us-gaap_StatementLineItems_378439" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract" xlink:label="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378439" xlink:to="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearFour" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearFour_378446" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearFour_378446" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearTwo" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearTwo_378443" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearTwo_378443" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityUndiscountedExcessAmount" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityUndiscountedExcessAmount_406020" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityUndiscountedExcessAmount_406020" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityPaymentsDue" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDue_378449" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDue_378449" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueAfterYearFive" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueAfterYearFive_378448" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueAfterYearFive_378448" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingLeaseLiability" xlink:label="loc_us-gaap_OperatingLeaseLiability_378451" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_OperatingLeaseLiability_378451" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityPaymentsRemainderOfFiscalYear" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsRemainderOfFiscalYear_900106" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsRemainderOfFiscalYear_900106" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearThree" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearThree_378444" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueYearThree_378444" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueNextTwelveMonths" xlink:label="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueNextTwelveMonths_378442" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_OperatingLeaseLiabilitiesPaymentsDueAbstract_378441" xlink:to="loc_us-gaap_LesseeOperatingLeaseLiabilityPaymentsDueNextTwelveMonths_378442" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementTable" xlink:label="loc_us-gaap_StatementTable_378436" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_StatementLineItems_378439" xlink:to="loc_us-gaap_StatementTable_378436" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="11" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockholdersEquityAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EquityClassOfTreasuryStockLineItems" xlink:label="loc_us-gaap_EquityClassOfTreasuryStockLineItems_376" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TreasuryStockSharesAcquired" xlink:label="loc_us-gaap_TreasuryStockSharesAcquired_384" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityClassOfTreasuryStockLineItems_376" xlink:to="loc_us-gaap_TreasuryStockSharesAcquired_384" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CommonStockSharesAuthorized" xlink:label="loc_us-gaap_CommonStockSharesAuthorized_380" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityClassOfTreasuryStockLineItems_376" xlink:to="loc_us-gaap_CommonStockSharesAuthorized_380" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CommonStockParOrStatedValuePerShare" xlink:label="loc_us-gaap_CommonStockParOrStatedValuePerShare_1409337" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityClassOfTreasuryStockLineItems_376" xlink:to="loc_us-gaap_CommonStockParOrStatedValuePerShare_1409337" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ClassOfTreasuryStockTable" xlink:label="loc_us-gaap_ClassOfTreasuryStockTable_375" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_EquityClassOfTreasuryStockLineItems_376" xlink:to="loc_us-gaap_ClassOfTreasuryStockTable_375" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SubsequentEventTypeAxis" xlink:label="loc_us-gaap_SubsequentEventTypeAxis_1409338" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ClassOfTreasuryStockTable_375" xlink:to="loc_us-gaap_SubsequentEventTypeAxis_1409338" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SubsequentEventTypeDomain" xlink:label="loc_us-gaap_SubsequentEventTypeDomain_1409339" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_SubsequentEventTypeAxis_1409338" xlink:to="loc_us-gaap_SubsequentEventTypeDomain_1409339" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SubsequentEventTypeDomain" xlink:label="loc_us-gaap_SubsequentEventTypeDomain_1409339_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_SubsequentEventTypeAxis_1409338" xlink:to="loc_us-gaap_SubsequentEventTypeDomain_1409339_default" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareRepurchaseProgramAxis" xlink:label="loc_us-gaap_ShareRepurchaseProgramAxis_377" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ClassOfTreasuryStockTable_375" xlink:to="loc_us-gaap_ShareRepurchaseProgramAxis_377" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareRepurchaseProgramDomain" xlink:label="loc_us-gaap_ShareRepurchaseProgramDomain_378" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_ShareRepurchaseProgramAxis_377" xlink:to="loc_us-gaap_ShareRepurchaseProgramDomain_378" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareRepurchaseProgramDomain" xlink:label="loc_us-gaap_ShareRepurchaseProgramDomain_378_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_ShareRepurchaseProgramAxis_377" xlink:to="loc_us-gaap_ShareRepurchaseProgramDomain_378_default" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_StockRepurchaseProgramMember" xlink:label="loc_trex_StockRepurchaseProgramMember_389" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareRepurchaseProgramDomain_378" xlink:to="loc_trex_StockRepurchaseProgramMember_389" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementEquityComponentsAxis" xlink:label="loc_us-gaap_StatementEquityComponentsAxis_900129" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ClassOfTreasuryStockTable_375" xlink:to="loc_us-gaap_StatementEquityComponentsAxis_900129" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EquityComponentDomain" xlink:label="loc_us-gaap_EquityComponentDomain_900130" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_StatementEquityComponentsAxis_900129" xlink:to="loc_us-gaap_EquityComponentDomain_900130" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EquityComponentDomain" xlink:label="loc_us-gaap_EquityComponentDomain_900130_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_StatementEquityComponentsAxis_900129" xlink:to="loc_us-gaap_EquityComponentDomain_900130_default" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockRepurchaseProgramNumberOfSharesAuthorizedToBeRepurchased" xlink:label="loc_us-gaap_StockRepurchaseProgramNumberOfSharesAuthorizedToBeRepurchased_383" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_EquityClassOfTreasuryStockLineItems_376" xlink:to="loc_us-gaap_StockRepurchaseProgramNumberOfSharesAuthorizedToBeRepurchased_383" use="optional" order="15" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockholdersEquityComputationOfBasicAndDilutedEarningsPerShareDetail">
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems" xlink:label="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems_393" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_WeightedAverageNumberDilutedSharesOutstandingAdjustmentAbstract" xlink:label="loc_us-gaap_WeightedAverageNumberDilutedSharesOutstandingAdjustmentAbstract_397" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems_393" xlink:to="loc_us-gaap_WeightedAverageNumberDilutedSharesOutstandingAdjustmentAbstract_397" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncrementalCommonSharesAttributableToShareBasedPaymentArrangements" xlink:label="loc_us-gaap_IncrementalCommonSharesAttributableToShareBasedPaymentArrangements_404" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_WeightedAverageNumberDilutedSharesOutstandingAdjustmentAbstract_397" xlink:to="loc_us-gaap_IncrementalCommonSharesAttributableToShareBasedPaymentArrangements_404" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_WeightedAverageNumberOfDilutedSharesOutstanding" xlink:label="loc_us-gaap_WeightedAverageNumberOfDilutedSharesOutstanding_405" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_WeightedAverageNumberDilutedSharesOutstandingAdjustmentAbstract_397" xlink:to="loc_us-gaap_WeightedAverageNumberOfDilutedSharesOutstanding_405" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EarningsPerShareDiluted" xlink:label="loc_us-gaap_EarningsPerShareDiluted_400" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems_393" xlink:to="loc_us-gaap_EarningsPerShareDiluted_400" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_NetIncomeLossAbstract" xlink:label="loc_us-gaap_NetIncomeLossAbstract_395" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems_393" xlink:to="loc_us-gaap_NetIncomeLossAbstract_395" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_NetIncomeLoss" xlink:label="loc_us-gaap_NetIncomeLoss_401" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_NetIncomeLossAbstract_395" xlink:to="loc_us-gaap_NetIncomeLoss_401" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ComponentsOfBasicAndDilutedEarningPerShareTable" xlink:label="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareTable_394" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems_393" xlink:to="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareTable_394" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AwardTypeAxis" xlink:label="loc_us-gaap_AwardTypeAxis_392" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareTable_394" xlink:to="loc_us-gaap_AwardTypeAxis_392" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_396" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AwardTypeAxis_392" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_396" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_396_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AwardTypeAxis_392" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_396_default" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_RestrictedStockMember" xlink:label="loc_us-gaap_RestrictedStockMember_403" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_396" xlink:to="loc_us-gaap_RestrictedStockMember_403" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_StockAppreciationRightsMember" xlink:label="loc_trex_StockAppreciationRightsMember_402" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_396" xlink:to="loc_trex_StockAppreciationRightsMember_402" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_WeightedAverageNumberOfSharesOutstandingBasicAbstract" xlink:label="loc_us-gaap_WeightedAverageNumberOfSharesOutstandingBasicAbstract_398" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems_393" xlink:to="loc_us-gaap_WeightedAverageNumberOfSharesOutstandingBasicAbstract_398" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_WeightedAverageNumberOfSharesOutstandingBasic" xlink:label="loc_us-gaap_WeightedAverageNumberOfSharesOutstandingBasic_406" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_WeightedAverageNumberOfSharesOutstandingBasicAbstract_398" xlink:to="loc_us-gaap_WeightedAverageNumberOfSharesOutstandingBasic_406" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EarningsPerShareBasic" xlink:label="loc_us-gaap_EarningsPerShareBasic_399" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ComponentsOfBasicAndDilutedEarningPerShareLineItems_393" xlink:to="loc_us-gaap_EarningsPerShareBasic_399" use="optional" order="15" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockholdersEquityAntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareLineItems" xlink:label="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareLineItems_410" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareAmount" xlink:label="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareAmount_413" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareLineItems_410" xlink:to="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareAmount_413" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfAntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareTable" xlink:label="loc_us-gaap_ScheduleOfAntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareTable_412" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareLineItems_410" xlink:to="loc_us-gaap_ScheduleOfAntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareTable_412" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareByAntidilutiveSecuritiesAxis" xlink:label="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareByAntidilutiveSecuritiesAxis_409" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfAntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareTable_412" xlink:to="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareByAntidilutiveSecuritiesAxis_409" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AntidilutiveSecuritiesNameDomain" xlink:label="loc_us-gaap_AntidilutiveSecuritiesNameDomain_411" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareByAntidilutiveSecuritiesAxis_409" xlink:to="loc_us-gaap_AntidilutiveSecuritiesNameDomain_411" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AntidilutiveSecuritiesNameDomain" xlink:label="loc_us-gaap_AntidilutiveSecuritiesNameDomain_411_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AntidilutiveSecuritiesExcludedFromComputationOfEarningsPerShareByAntidilutiveSecuritiesAxis_409" xlink:to="loc_us-gaap_AntidilutiveSecuritiesNameDomain_411_default" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockAppreciationRightsSARSMember" xlink:label="loc_us-gaap_StockAppreciationRightsSARSMember_415" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_AntidilutiveSecuritiesNameDomain_411" xlink:to="loc_us-gaap_StockAppreciationRightsSARSMember_415" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_RestrictedStockMember" xlink:label="loc_us-gaap_RestrictedStockMember_560984" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_AntidilutiveSecuritiesNameDomain_411" xlink:to="loc_us-gaap_RestrictedStockMember_560984" use="optional" order="7" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/RevenueFromContractsWithCustomersSummaryOfDisaggregatedNetSalesDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DisaggregationOfRevenueLineItems" xlink:label="loc_us-gaap_DisaggregationOfRevenueLineItems_422" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DisaggregationOfRevenueTable" xlink:label="loc_us-gaap_DisaggregationOfRevenueTable_423" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_DisaggregationOfRevenueLineItems_422" xlink:to="loc_us-gaap_DisaggregationOfRevenueTable_423" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentAxis" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_424" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_DisaggregationOfRevenueTable_423" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_424" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_425" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_424" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_425" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_425_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_424" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_425_default" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ResidentialPortfolioSegmentMember" xlink:label="loc_us-gaap_ResidentialPortfolioSegmentMember_429" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_425" xlink:to="loc_us-gaap_ResidentialPortfolioSegmentMember_429" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CommercialPortfolioSegmentMember" xlink:label="loc_us-gaap_CommercialPortfolioSegmentMember_430" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_425" xlink:to="loc_us-gaap_CommercialPortfolioSegmentMember_430" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TimingOfTransferOfGoodOrServiceAxis" xlink:label="loc_us-gaap_TimingOfTransferOfGoodOrServiceAxis_426" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_DisaggregationOfRevenueTable_423" xlink:to="loc_us-gaap_TimingOfTransferOfGoodOrServiceAxis_426" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TimingOfTransferOfGoodOrServiceDomain" xlink:label="loc_us-gaap_TimingOfTransferOfGoodOrServiceDomain_427" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_TimingOfTransferOfGoodOrServiceAxis_426" xlink:to="loc_us-gaap_TimingOfTransferOfGoodOrServiceDomain_427" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TimingOfTransferOfGoodOrServiceDomain" xlink:label="loc_us-gaap_TimingOfTransferOfGoodOrServiceDomain_427_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_TimingOfTransferOfGoodOrServiceAxis_426" xlink:to="loc_us-gaap_TimingOfTransferOfGoodOrServiceDomain_427_default" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TransferredOverTimeMember" xlink:label="loc_us-gaap_TransferredOverTimeMember_432" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_TimingOfTransferOfGoodOrServiceDomain_427" xlink:to="loc_us-gaap_TransferredOverTimeMember_432" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TransferredAtPointInTimeMember" xlink:label="loc_us-gaap_TransferredAtPointInTimeMember_431" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_TimingOfTransferOfGoodOrServiceDomain_427" xlink:to="loc_us-gaap_TransferredAtPointInTimeMember_431" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax" xlink:label="loc_us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax_428" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_DisaggregationOfRevenueLineItems_422" xlink:to="loc_us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax_428" use="optional" order="12" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockBasedCompensationAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_441" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EmployeeServiceShareBasedCompensationNonvestedAwardsTotalCompensationCostNotYetRecognizedShareBasedAwardsOtherThanOptions" xlink:label="loc_us-gaap_EmployeeServiceShareBasedCompensationNonvestedAwardsTotalCompensationCostNotYetRecognizedShareBasedAwardsOtherThanOptions_450" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_441" xlink:to="loc_us-gaap_EmployeeServiceShareBasedCompensationNonvestedAwardsTotalCompensationCostNotYetRecognizedShareBasedAwardsOtherThanOptions_450" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsMethodUsed" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsMethodUsed_456" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_441" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsMethodUsed_456" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardNumberOfSharesAuthorized" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardNumberOfSharesAuthorized_448" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_441" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardNumberOfSharesAuthorized_448" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriod" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriod_457" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_441" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriod_457" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CommonStockCapitalSharesReservedForFutureIssuance" xlink:label="loc_us-gaap_CommonStockCapitalSharesReservedForFutureIssuance_378587" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_441" xlink:to="loc_us-gaap_CommonStockCapitalSharesReservedForFutureIssuance_378587" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable" xlink:label="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_440" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_441" xlink:to="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_440" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_PlanNameAxis" xlink:label="loc_us-gaap_PlanNameAxis_436" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_440" xlink:to="loc_us-gaap_PlanNameAxis_436" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_PlanNameDomain" xlink:label="loc_us-gaap_PlanNameDomain_437" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_PlanNameAxis_436" xlink:to="loc_us-gaap_PlanNameDomain_437" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_PlanNameDomain" xlink:label="loc_us-gaap_PlanNameDomain_437_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_PlanNameAxis_436" xlink:to="loc_us-gaap_PlanNameDomain_437_default" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_TwoThousandFourteenStockIncentivePlanMember" xlink:label="loc_trex_TwoThousandFourteenStockIncentivePlanMember_445" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_PlanNameDomain_437" xlink:to="loc_trex_TwoThousandFourteenStockIncentivePlanMember_445" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeAxis" xlink:label="loc_srt_RangeAxis_561151" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_440" xlink:to="loc_srt_RangeAxis_561151" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeMember" xlink:label="loc_srt_RangeMember_561152" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_srt_RangeAxis_561151" xlink:to="loc_srt_RangeMember_561152" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeMember" xlink:label="loc_srt_RangeMember_561152_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_srt_RangeAxis_561151" xlink:to="loc_srt_RangeMember_561152_default" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AwardTypeAxis" xlink:label="loc_us-gaap_AwardTypeAxis_435" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_440" xlink:to="loc_us-gaap_AwardTypeAxis_435" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_442" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AwardTypeAxis_435" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_442" use="optional" order="15" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_442_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AwardTypeAxis_435" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_442_default" use="optional" order="16" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_PerformanceBasedRestrictedStockAndPerformanceBasedRestrictedStockUnitsMember" xlink:label="loc_trex_PerformanceBasedRestrictedStockAndPerformanceBasedRestrictedStockUnitsMember_462" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_442" xlink:to="loc_trex_PerformanceBasedRestrictedStockAndPerformanceBasedRestrictedStockUnitsMember_462" use="optional" order="17" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockAppreciationRightsSARSMember" xlink:label="loc_us-gaap_StockAppreciationRightsSARSMember_463" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_442" xlink:to="loc_us-gaap_StockAppreciationRightsSARSMember_463" use="optional" order="18" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_PerformanceBasedRestrictedStockAdjustmentMember" xlink:label="loc_trex_PerformanceBasedRestrictedStockAdjustmentMember_1562917" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_442" xlink:to="loc_trex_PerformanceBasedRestrictedStockAdjustmentMember_1562917" use="optional" order="19" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_VestingAxis" xlink:label="loc_us-gaap_VestingAxis_443" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_440" xlink:to="loc_us-gaap_VestingAxis_443" use="optional" order="20" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_VestingDomain" xlink:label="loc_us-gaap_VestingDomain_444" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_VestingAxis_443" xlink:to="loc_us-gaap_VestingDomain_444" use="optional" order="21" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_VestingDomain" xlink:label="loc_us-gaap_VestingDomain_444_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_VestingAxis_443" xlink:to="loc_us-gaap_VestingDomain_444_default" use="optional" order="22" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockBasedCompensationSummaryOfStockBasedCompensationGrantsDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementLineItems" xlink:label="loc_us-gaap_StatementLineItems_378555" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriod" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriod_378557" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378555" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriod_378557" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardNonOptionsEquityInstrumentsGrantedWeightedAverageGrantPrice" xlink:label="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardNonOptionsEquityInstrumentsGrantedWeightedAverageGrantPrice_378561" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_StatementLineItems_378555" xlink:to="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardNonOptionsEquityInstrumentsGrantedWeightedAverageGrantPrice_378561" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementTable" xlink:label="loc_us-gaap_StatementTable_378552" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_StatementLineItems_378555" xlink:to="loc_us-gaap_StatementTable_378552" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AwardTypeAxis" xlink:label="loc_us-gaap_AwardTypeAxis_378563" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_StatementTable_378552" xlink:to="loc_us-gaap_AwardTypeAxis_378563" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_378564" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AwardTypeAxis_378563" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_378564" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_378564_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AwardTypeAxis_378563" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_378564_default" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_PerformanceBasedRestrictedStockUnitsMember" xlink:label="loc_trex_PerformanceBasedRestrictedStockUnitsMember_378566" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_378564" xlink:to="loc_trex_PerformanceBasedRestrictedStockUnitsMember_378566" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_TimeBasedRestrictedStockUnitsMember" xlink:label="loc_trex_TimeBasedRestrictedStockUnitsMember_378565" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_378564" xlink:to="loc_trex_TimeBasedRestrictedStockUnitsMember_378565" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockAppreciationRightsSARSMember" xlink:label="loc_us-gaap_StockAppreciationRightsSARSMember_378567" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_378564" xlink:to="loc_us-gaap_StockAppreciationRightsSARSMember_378567" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StatementClassOfStockAxis" xlink:label="loc_us-gaap_StatementClassOfStockAxis_378553" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_StatementTable_378552" xlink:to="loc_us-gaap_StatementClassOfStockAxis_378553" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ClassOfStockDomain" xlink:label="loc_us-gaap_ClassOfStockDomain_378554" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_StatementClassOfStockAxis_378553" xlink:to="loc_us-gaap_ClassOfStockDomain_378554" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ClassOfStockDomain" xlink:label="loc_us-gaap_ClassOfStockDomain_378554_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_StatementClassOfStockAxis_378553" xlink:to="loc_us-gaap_ClassOfStockDomain_378554_default" use="optional" order="12" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockBasedCompensationSummaryOfAssumptionsUsedToEstimateFairValueOfEachSarDetail">
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems" xlink:label="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems_517" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsRiskFreeInterestRate" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsRiskFreeInterestRate_521" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems_517" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsRiskFreeInterestRate_521" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SharebasedCompensationArrangementBySharebasedPaymentAwardFairValueAssumptionsExpectedTerm1" xlink:label="loc_us-gaap_SharebasedCompensationArrangementBySharebasedPaymentAwardFairValueAssumptionsExpectedTerm1_522" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems_517" xlink:to="loc_us-gaap_SharebasedCompensationArrangementBySharebasedPaymentAwardFairValueAssumptionsExpectedTerm1_522" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyTable" xlink:label="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyTable_518" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems_517" xlink:to="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyTable_518" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AwardTypeAxis" xlink:label="loc_us-gaap_AwardTypeAxis_516" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyTable_518" xlink:to="loc_us-gaap_AwardTypeAxis_516" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_519" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AwardTypeAxis_516" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_519" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_519_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AwardTypeAxis_516" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_519_default" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockAppreciationRightsSARSMember" xlink:label="loc_us-gaap_StockAppreciationRightsSARSMember_524" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_519" xlink:to="loc_us-gaap_StockAppreciationRightsSARSMember_524" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsExpectedDividendRate" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsExpectedDividendRate_520" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems_517" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsExpectedDividendRate_520" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriodWeightedAverageGrantDateFairValue" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriodWeightedAverageGrantDateFairValue_378585" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems_517" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardEquityInstrumentsOtherThanOptionsGrantsInPeriodWeightedAverageGrantDateFairValue_378585" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsExpectedVolatilityRate" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsExpectedVolatilityRate_523" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsAndMethodologyLineItems_517" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardFairValueAssumptionsExpectedVolatilityRate_523" use="optional" order="10" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/StockBasedCompensationSummaryOfStockBasedCompensationExpensesDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_473" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AllocatedShareBasedCompensationExpense" xlink:label="loc_us-gaap_AllocatedShareBasedCompensationExpense_475" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_473" xlink:to="loc_us-gaap_AllocatedShareBasedCompensationExpense_475" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable" xlink:label="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_472" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementByShareBasedPaymentAwardLineItems_473" xlink:to="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_472" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AwardTypeAxis" xlink:label="loc_us-gaap_AwardTypeAxis_471" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfShareBasedCompensationArrangementsByShareBasedPaymentAwardTable_472" xlink:to="loc_us-gaap_AwardTypeAxis_471" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AwardTypeAxis_471" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain" xlink:label="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AwardTypeAxis_471" xlink:to="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474_default" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StockAppreciationRightsSARSMember" xlink:label="loc_us-gaap_StockAppreciationRightsSARSMember_478" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474" xlink:to="loc_us-gaap_StockAppreciationRightsSARSMember_478" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_TimeBasedRestrictedStockandRestrictedstockUnitsMember" xlink:label="loc_trex_TimeBasedRestrictedStockandRestrictedstockUnitsMember_580537" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474" xlink:to="loc_trex_TimeBasedRestrictedStockandRestrictedstockUnitsMember_580537" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_PerformanceBasedRestrictedStockAndrestrictedStockunitsMember" xlink:label="loc_trex_PerformanceBasedRestrictedStockAndrestrictedStockunitsMember_580538" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474" xlink:to="loc_trex_PerformanceBasedRestrictedStockAndrestrictedStockunitsMember_580538" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_EmployeeStockPurchasePlanMember" xlink:label="loc_trex_EmployeeStockPurchasePlanMember_479" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ShareBasedCompensationArrangementsByShareBasedPaymentAwardAwardTypeAndPlanNameDomain_474" xlink:to="loc_trex_EmployeeStockPurchasePlanMember_479" use="optional" order="9" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/IncomeTaxesAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxContingencyLineItems" xlink:label="loc_us-gaap_IncomeTaxContingencyLineItems_621" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OpenTaxYear" xlink:label="loc_us-gaap_OpenTaxYear_630" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_IncomeTaxContingencyLineItems_621" xlink:to="loc_us-gaap_OpenTaxYear_630" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EffectiveIncomeTaxRateContinuingOperations" xlink:label="loc_us-gaap_EffectiveIncomeTaxRateContinuingOperations_378586" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_IncomeTaxContingencyLineItems_621" xlink:to="loc_us-gaap_EffectiveIncomeTaxRateContinuingOperations_378586" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxExpenseBenefit" xlink:label="loc_us-gaap_IncomeTaxExpenseBenefit_627" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_IncomeTaxContingencyLineItems_621" xlink:to="loc_us-gaap_IncomeTaxExpenseBenefit_627" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxContingencyTable" xlink:label="loc_us-gaap_IncomeTaxContingencyTable_622" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_IncomeTaxContingencyLineItems_621" xlink:to="loc_us-gaap_IncomeTaxContingencyTable_622" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TaxPeriodAxis" xlink:label="loc_us-gaap_TaxPeriodAxis_378593" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_IncomeTaxContingencyTable_622" xlink:to="loc_us-gaap_TaxPeriodAxis_378593" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TaxPeriodDomain" xlink:label="loc_us-gaap_TaxPeriodDomain_378594" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_TaxPeriodAxis_378593" xlink:to="loc_us-gaap_TaxPeriodDomain_378594" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TaxPeriodDomain" xlink:label="loc_us-gaap_TaxPeriodDomain_378594_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_TaxPeriodAxis_378593" xlink:to="loc_us-gaap_TaxPeriodDomain_378594_default" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LatestTaxYearMember" xlink:label="loc_us-gaap_LatestTaxYearMember_378596" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_TaxPeriodDomain_378594" xlink:to="loc_us-gaap_LatestTaxYearMember_378596" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_EarliestTaxYearMember" xlink:label="loc_us-gaap_EarliestTaxYearMember_378595" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_TaxPeriodDomain_378594" xlink:to="loc_us-gaap_EarliestTaxYearMember_378595" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AdjustmentsForNewAccountingPronouncementsAxis" xlink:label="loc_us-gaap_AdjustmentsForNewAccountingPronouncementsAxis_620" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_IncomeTaxContingencyTable_622" xlink:to="loc_us-gaap_AdjustmentsForNewAccountingPronouncementsAxis_620" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TypeOfAdoptionMember" xlink:label="loc_us-gaap_TypeOfAdoptionMember_623" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_AdjustmentsForNewAccountingPronouncementsAxis_620" xlink:to="loc_us-gaap_TypeOfAdoptionMember_623" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_TypeOfAdoptionMember" xlink:label="loc_us-gaap_TypeOfAdoptionMember_623_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_AdjustmentsForNewAccountingPronouncementsAxis_620" xlink:to="loc_us-gaap_TypeOfAdoptionMember_623_default" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxAuthorityNameAxis" xlink:label="loc_us-gaap_IncomeTaxAuthorityNameAxis_378597" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_IncomeTaxContingencyTable_622" xlink:to="loc_us-gaap_IncomeTaxAuthorityNameAxis_378597" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxAuthorityNameDomain" xlink:label="loc_us-gaap_IncomeTaxAuthorityNameDomain_378598" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_IncomeTaxAuthorityNameAxis_378597" xlink:to="loc_us-gaap_IncomeTaxAuthorityNameDomain_378598" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxAuthorityNameDomain" xlink:label="loc_us-gaap_IncomeTaxAuthorityNameDomain_378598_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_IncomeTaxAuthorityNameAxis_378597" xlink:to="loc_us-gaap_IncomeTaxAuthorityNameDomain_378598_default" use="optional" order="15" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_InternalRevenueServiceIRSMember" xlink:label="loc_us-gaap_InternalRevenueServiceIRSMember_378600" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_IncomeTaxAuthorityNameDomain_378598" xlink:to="loc_us-gaap_InternalRevenueServiceIRSMember_378600" use="optional" order="16" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DeferredTaxAssetsValuationAllowance" xlink:label="loc_us-gaap_DeferredTaxAssetsValuationAllowance_626" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_IncomeTaxContingencyLineItems_621" xlink:to="loc_us-gaap_DeferredTaxAssetsValuationAllowance_626" use="optional" order="17" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ExcessTaxBenefitsFromStockBasedAwards" xlink:label="loc_trex_ExcessTaxBenefitsFromStockBasedAwards_1563005" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_IncomeTaxContingencyLineItems_621" xlink:to="loc_trex_ExcessTaxBenefitsFromStockBasedAwards_1563005" use="optional" order="18" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/SegmentInformationAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SegmentReportingInformationLineItems" xlink:label="loc_us-gaap_SegmentReportingInformationLineItems_637" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable" xlink:label="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_636" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_637" xlink:to="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_636" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentAxis" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_634" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_636" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_634" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_635" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_634" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_635" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_635_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_634" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_635_default" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_NumberOfReportableSegments" xlink:label="loc_us-gaap_NumberOfReportableSegments_640" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_637" xlink:to="loc_us-gaap_NumberOfReportableSegments_640" use="optional" order="5" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/SegmentInformationDetailsOfSegmentInformationDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SegmentReportingInformationLineItems" xlink:label="loc_us-gaap_SegmentReportingInformationLineItems_650" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DepreciationDepletionAndAmortization" xlink:label="loc_us-gaap_DepreciationDepletionAndAmortization_657" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_us-gaap_DepreciationDepletionAndAmortization_657" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_Assets" xlink:label="loc_us-gaap_Assets_660" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_us-gaap_Assets_660" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_CapitalExpenditure" xlink:label="loc_trex_CapitalExpenditure_659" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_trex_CapitalExpenditure_659" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax" xlink:label="loc_us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax_654" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax_654" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_NetIncomeLoss" xlink:label="loc_us-gaap_NetIncomeLoss_655" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_us-gaap_NetIncomeLoss_655" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_EBITDA" xlink:label="loc_trex_EBITDA_656" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_trex_EBITDA_656" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxExpenseBenefit" xlink:label="loc_us-gaap_IncomeTaxExpenseBenefit_658" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_us-gaap_IncomeTaxExpenseBenefit_658" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable" xlink:label="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_649" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_650" xlink:to="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_649" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ConsolidationItemsAxis" xlink:label="loc_srt_ConsolidationItemsAxis_645" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_649" xlink:to="loc_srt_ConsolidationItemsAxis_645" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ConsolidationItemsDomain" xlink:label="loc_srt_ConsolidationItemsDomain_646" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_srt_ConsolidationItemsAxis_645" xlink:to="loc_srt_ConsolidationItemsDomain_646" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ConsolidationItemsDomain" xlink:label="loc_srt_ConsolidationItemsDomain_646_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_srt_ConsolidationItemsAxis_645" xlink:to="loc_srt_ConsolidationItemsDomain_646_default" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingSegmentsMember" xlink:label="loc_us-gaap_OperatingSegmentsMember_651" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_srt_ConsolidationItemsDomain_646" xlink:to="loc_us-gaap_OperatingSegmentsMember_651" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentAxis" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_647" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_649" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_647" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_648" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_647" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_648" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_648_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_647" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_648_default" use="optional" order="15" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CommercialPortfolioSegmentMember" xlink:label="loc_us-gaap_CommercialPortfolioSegmentMember_653" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_648" xlink:to="loc_us-gaap_CommercialPortfolioSegmentMember_653" use="optional" order="16" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ResidentialPortfolioSegmentMember" xlink:label="loc_us-gaap_ResidentialPortfolioSegmentMember_652" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_648" xlink:to="loc_us-gaap_ResidentialPortfolioSegmentMember_652" use="optional" order="17" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/SegmentInformationScheduleOfReconciliationOfNetIncomeToEbitdaDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_SegmentReportingInformationLineItems" xlink:label="loc_us-gaap_SegmentReportingInformationLineItems_668" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_EBITDA" xlink:label="loc_trex_EBITDA_676" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_668" xlink:to="loc_trex_EBITDA_676" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_NetIncomeLoss" xlink:label="loc_us-gaap_NetIncomeLoss_672" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_668" xlink:to="loc_us-gaap_NetIncomeLoss_672" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_DepreciationDepletionAndAmortization" xlink:label="loc_us-gaap_DepreciationDepletionAndAmortization_675" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_668" xlink:to="loc_us-gaap_DepreciationDepletionAndAmortization_675" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_IncomeTaxExpenseBenefit" xlink:label="loc_us-gaap_IncomeTaxExpenseBenefit_674" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_668" xlink:to="loc_us-gaap_IncomeTaxExpenseBenefit_674" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable" xlink:label="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_667" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_668" xlink:to="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_667" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentAxis" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_665" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_667" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_665" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_666" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_665" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_666" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_666_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_665" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_666_default" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ResidentialPortfolioSegmentMember" xlink:label="loc_us-gaap_ResidentialPortfolioSegmentMember_670" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_666" xlink:to="loc_us-gaap_ResidentialPortfolioSegmentMember_670" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_CommercialPortfolioSegmentMember" xlink:label="loc_us-gaap_CommercialPortfolioSegmentMember_671" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_666" xlink:to="loc_us-gaap_CommercialPortfolioSegmentMember_671" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ConsolidationItemsAxis" xlink:label="loc_srt_ConsolidationItemsAxis_663" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ScheduleOfSegmentReportingInformationBySegmentTable_667" xlink:to="loc_srt_ConsolidationItemsAxis_663" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ConsolidationItemsDomain" xlink:label="loc_srt_ConsolidationItemsDomain_664" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_srt_ConsolidationItemsAxis_663" xlink:to="loc_srt_ConsolidationItemsDomain_664" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ConsolidationItemsDomain" xlink:label="loc_srt_ConsolidationItemsDomain_664_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_srt_ConsolidationItemsAxis_663" xlink:to="loc_srt_ConsolidationItemsDomain_664_default" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_OperatingSegmentsMember" xlink:label="loc_us-gaap_OperatingSegmentsMember_669" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_srt_ConsolidationItemsDomain_664" xlink:to="loc_us-gaap_OperatingSegmentsMember_669" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_InterestIncomeExpenseNet" xlink:label="loc_us-gaap_InterestIncomeExpenseNet_673" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_SegmentReportingInformationLineItems_668" xlink:to="loc_us-gaap_InterestIncomeExpenseNet_673" use="optional" order="15" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/CommitmentsAndContingenciesAdditionalInformationDetail">
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ScheduleOfCommitmentsAndContingenciesLineItems" xlink:label="loc_trex_ScheduleOfCommitmentsAndContingenciesLineItems_687" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_SensitivityChangeInSurfaceFlakingWarrantyReserve" xlink:label="loc_trex_SensitivityChangeInSurfaceFlakingWarrantyReserve_705" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesLineItems_687" xlink:to="loc_trex_SensitivityChangeInSurfaceFlakingWarrantyReserve_705" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_ScheduleOfCommitmentsAndContingenciesTable" xlink:label="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesLineItems_687" xlink:to="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ValuationAllowancesAndReservesTypeAxis" xlink:label="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_690" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_690" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ValuationAllowancesAndReservesDomain" xlink:label="loc_us-gaap_ValuationAllowancesAndReservesDomain_689" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_690" xlink:to="loc_us-gaap_ValuationAllowancesAndReservesDomain_689" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ValuationAllowancesAndReservesDomain" xlink:label="loc_us-gaap_ValuationAllowancesAndReservesDomain_689_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_690" xlink:to="loc_us-gaap_ValuationAllowancesAndReservesDomain_689_default" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_SurfaceFlakingWarrantyReserveMember" xlink:label="loc_trex_SurfaceFlakingWarrantyReserveMember_706" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ValuationAllowancesAndReservesDomain_689" xlink:to="loc_trex_SurfaceFlakingWarrantyReserveMember_706" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_GuaranteeObligationsByNatureAxis" xlink:label="loc_us-gaap_GuaranteeObligationsByNatureAxis_679" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_us-gaap_GuaranteeObligationsByNatureAxis_679" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_GuaranteeObligationsNatureDomain" xlink:label="loc_us-gaap_GuaranteeObligationsNatureDomain_680" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_GuaranteeObligationsByNatureAxis_679" xlink:to="loc_us-gaap_GuaranteeObligationsNatureDomain_680" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_GuaranteeObligationsNatureDomain" xlink:label="loc_us-gaap_GuaranteeObligationsNatureDomain_680_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_GuaranteeObligationsByNatureAxis_679" xlink:to="loc_us-gaap_GuaranteeObligationsNatureDomain_680_default" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_CommercialUseMember" xlink:label="loc_trex_CommercialUseMember_692" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_GuaranteeObligationsNatureDomain_680" xlink:to="loc_trex_CommercialUseMember_692" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeAxis" xlink:label="loc_srt_RangeAxis_685" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_srt_RangeAxis_685" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeMember" xlink:label="loc_srt_RangeMember_686" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_srt_RangeAxis_685" xlink:to="loc_srt_RangeMember_686" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_RangeMember" xlink:label="loc_srt_RangeMember_686_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_srt_RangeAxis_685" xlink:to="loc_srt_RangeMember_686_default" use="optional" order="13" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_MinimumMember" xlink:label="loc_srt_MinimumMember_697" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_srt_RangeMember_686" xlink:to="loc_srt_MinimumMember_697" use="optional" order="14" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_MaximumMember" xlink:label="loc_srt_MaximumMember_698" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_srt_RangeMember_686" xlink:to="loc_srt_MaximumMember_698" use="optional" order="15" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LongTermPurchaseCommitmentByCategoryOfItemPurchasedAxis" xlink:label="loc_us-gaap_LongTermPurchaseCommitmentByCategoryOfItemPurchasedAxis_681" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_us-gaap_LongTermPurchaseCommitmentByCategoryOfItemPurchasedAxis_681" use="optional" order="16" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LongTermPurchaseCommitmentCategoryOfItemPurchasedDomain" xlink:label="loc_us-gaap_LongTermPurchaseCommitmentCategoryOfItemPurchasedDomain_682" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_LongTermPurchaseCommitmentByCategoryOfItemPurchasedAxis_681" xlink:to="loc_us-gaap_LongTermPurchaseCommitmentCategoryOfItemPurchasedDomain_682" use="optional" order="17" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LongTermPurchaseCommitmentCategoryOfItemPurchasedDomain" xlink:label="loc_us-gaap_LongTermPurchaseCommitmentCategoryOfItemPurchasedDomain_682_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_LongTermPurchaseCommitmentByCategoryOfItemPurchasedAxis_681" xlink:to="loc_us-gaap_LongTermPurchaseCommitmentCategoryOfItemPurchasedDomain_682_default" use="optional" order="18" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_GainContingenciesByNatureAxis" xlink:label="loc_us-gaap_GainContingenciesByNatureAxis_1135585" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_us-gaap_GainContingenciesByNatureAxis_1135585" use="optional" order="19" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_GainContingencyNatureDomain" xlink:label="loc_us-gaap_GainContingencyNatureDomain_1135586" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_GainContingenciesByNatureAxis_1135585" xlink:to="loc_us-gaap_GainContingencyNatureDomain_1135586" use="optional" order="20" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_GainContingencyNatureDomain" xlink:label="loc_us-gaap_GainContingencyNatureDomain_1135586_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_GainContingenciesByNatureAxis_1135585" xlink:to="loc_us-gaap_GainContingencyNatureDomain_1135586_default" use="optional" order="21" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ContingentConsiderationByTypeAxis" xlink:label="loc_us-gaap_ContingentConsiderationByTypeAxis_803848" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_us-gaap_ContingentConsiderationByTypeAxis_803848" use="optional" order="22" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ContingentConsiderationTypeDomain" xlink:label="loc_us-gaap_ContingentConsiderationTypeDomain_803849" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_ContingentConsiderationByTypeAxis_803848" xlink:to="loc_us-gaap_ContingentConsiderationTypeDomain_803849" use="optional" order="23" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ContingentConsiderationTypeDomain" xlink:label="loc_us-gaap_ContingentConsiderationTypeDomain_803849_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_ContingentConsiderationByTypeAxis_803848" xlink:to="loc_us-gaap_ContingentConsiderationTypeDomain_803849_default" use="optional" order="24" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_UnusualOrInfrequentItemAxis" xlink:label="loc_us-gaap_UnusualOrInfrequentItemAxis_899734" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_us-gaap_UnusualOrInfrequentItemAxis_899734" use="optional" order="25" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_UnusualOrInfrequentItemDomain" xlink:label="loc_us-gaap_UnusualOrInfrequentItemDomain_899735" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_UnusualOrInfrequentItemAxis_899734" xlink:to="loc_us-gaap_UnusualOrInfrequentItemDomain_899735" use="optional" order="26" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_UnusualOrInfrequentItemDomain" xlink:label="loc_us-gaap_UnusualOrInfrequentItemDomain_899735_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_UnusualOrInfrequentItemAxis_899734" xlink:to="loc_us-gaap_UnusualOrInfrequentItemDomain_899735_default" use="optional" order="27" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ProductOrServiceAxis" xlink:label="loc_srt_ProductOrServiceAxis_561113" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_srt_ProductOrServiceAxis_561113" use="optional" order="28" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ProductsAndServicesDomain" xlink:label="loc_srt_ProductsAndServicesDomain_561114" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_srt_ProductOrServiceAxis_561113" xlink:to="loc_srt_ProductsAndServicesDomain_561114" use="optional" order="29" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/srt/2022/elts/srt-2022.xsd#srt_ProductsAndServicesDomain" xlink:label="loc_srt_ProductsAndServicesDomain_561114_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_srt_ProductOrServiceAxis_561113" xlink:to="loc_srt_ProductsAndServicesDomain_561114_default" use="optional" order="30" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_CommercialRailingAndStagingSystemsMember" xlink:label="loc_trex_CommercialRailingAndStagingSystemsMember_561184" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_srt_ProductsAndServicesDomain_561114" xlink:to="loc_trex_CommercialRailingAndStagingSystemsMember_561184" use="optional" order="31" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentAxis" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_1562892" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesTable_688" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_1562892" use="optional" order="32" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_1562893" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_1562892" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_1562893" use="optional" order="33" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_FinancingReceivablePortfolioSegmentDomain" xlink:label="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_1562893_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentAxis_1562892" xlink:to="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_1562893_default" use="optional" order="34" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ResidentialPortfolioSegmentMember" xlink:label="loc_us-gaap_ResidentialPortfolioSegmentMember_1562895" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_FinancingReceivablePortfolioSegmentDomain_1562893" xlink:to="loc_us-gaap_ResidentialPortfolioSegmentMember_1562895" use="optional" order="35" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_WarrantyPeriod" xlink:label="loc_trex_WarrantyPeriod_703" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesLineItems_687" xlink:to="loc_trex_WarrantyPeriod_703" use="optional" order="36" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_PercentSensitivityChangeInExpectedSurfaceFlakingClaims" xlink:label="loc_trex_PercentSensitivityChangeInExpectedSurfaceFlakingClaims_704" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesLineItems_687" xlink:to="loc_trex_PercentSensitivityChangeInExpectedSurfaceFlakingClaims_704" use="optional" order="37" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_AreaOfLand" xlink:label="loc_us-gaap_AreaOfLand_1562884" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesLineItems_687" xlink:to="loc_us-gaap_AreaOfLand_1562884" use="optional" order="38" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_LandAndLandImprovements" xlink:label="loc_us-gaap_LandAndLandImprovements_1562890" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_trex_ScheduleOfCommitmentsAndContingenciesLineItems_687" xlink:to="loc_us-gaap_LandAndLandImprovements_1562890" use="optional" order="39" />
</definitionLink>
<definitionLink xlink:type="extended" xlink:role="http://www.trex.com/role/CommitmentsAndContingenciesSummaryOfReconciliationOfCompanysResidentialProductWarrantyReserveDetail">
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ProductWarrantyLiabilityLineItems" xlink:label="loc_us-gaap_ProductWarrantyLiabilityLineItems_711" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StandardProductWarrantyAccrualPayments" xlink:label="loc_us-gaap_StandardProductWarrantyAccrualPayments_719" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ProductWarrantyLiabilityLineItems_711" xlink:to="loc_us-gaap_StandardProductWarrantyAccrualPayments_719" use="optional" order="1" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ProductWarrantyLiabilityTable" xlink:label="loc_us-gaap_ProductWarrantyLiabilityTable_712" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/all" xlink:from="loc_us-gaap_ProductWarrantyLiabilityLineItems_711" xlink:to="loc_us-gaap_ProductWarrantyLiabilityTable_712" xbrldt:contextElement="segment" xbrldt:closed="true" use="optional" order="2" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ValuationAllowancesAndReservesTypeAxis" xlink:label="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_714" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ProductWarrantyLiabilityTable_712" xlink:to="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_714" use="optional" order="3" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ValuationAllowancesAndReservesDomain" xlink:label="loc_us-gaap_ValuationAllowancesAndReservesDomain_713" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_714" xlink:to="loc_us-gaap_ValuationAllowancesAndReservesDomain_713" use="optional" order="4" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ValuationAllowancesAndReservesDomain" xlink:label="loc_us-gaap_ValuationAllowancesAndReservesDomain_713_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_ValuationAllowancesAndReservesTypeAxis_714" xlink:to="loc_us-gaap_ValuationAllowancesAndReservesDomain_713_default" use="optional" order="5" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_SurfaceFlakingWarrantyReserveMember" xlink:label="loc_trex_SurfaceFlakingWarrantyReserveMember_721" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ValuationAllowancesAndReservesDomain_713" xlink:to="loc_trex_SurfaceFlakingWarrantyReserveMember_721" use="optional" order="6" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ContingentConsiderationByTypeAxis" xlink:label="loc_us-gaap_ContingentConsiderationByTypeAxis_709" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/hypercube-dimension" xlink:from="loc_us-gaap_ProductWarrantyLiabilityTable_712" xlink:to="loc_us-gaap_ContingentConsiderationByTypeAxis_709" use="optional" order="7" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ContingentConsiderationTypeDomain" xlink:label="loc_us-gaap_ContingentConsiderationTypeDomain_710" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-domain" xlink:from="loc_us-gaap_ContingentConsiderationByTypeAxis_709" xlink:to="loc_us-gaap_ContingentConsiderationTypeDomain_710" use="optional" order="8" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_ContingentConsiderationTypeDomain" xlink:label="loc_us-gaap_ContingentConsiderationTypeDomain_710_default" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/dimension-default" xlink:from="loc_us-gaap_ContingentConsiderationByTypeAxis_709" xlink:to="loc_us-gaap_ContingentConsiderationTypeDomain_710_default" use="optional" order="9" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_SurfaceFlakingMember" xlink:label="loc_trex_SurfaceFlakingMember_715" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ContingentConsiderationTypeDomain_710" xlink:to="loc_trex_SurfaceFlakingMember_715" use="optional" order="10" />
<loc xlink:type="locator" xlink:href="trex-20220630.xsd#trex_OtherResidentialMember" xlink:label="loc_trex_OtherResidentialMember_716" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ContingentConsiderationTypeDomain_710" xlink:to="loc_trex_OtherResidentialMember_716" use="optional" order="11" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StandardProductWarrantyAccrualPreexistingIncreaseDecrease" xlink:label="loc_us-gaap_StandardProductWarrantyAccrualPreexistingIncreaseDecrease_718" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ProductWarrantyLiabilityLineItems_711" xlink:to="loc_us-gaap_StandardProductWarrantyAccrualPreexistingIncreaseDecrease_718" use="optional" order="12" />
<loc xlink:type="locator" xlink:href="https://xbrl.fasb.org/us-gaap/2022/elts/us-gaap-2022.xsd#us-gaap_StandardProductWarrantyAccrual" xlink:label="loc_us-gaap_StandardProductWarrantyAccrual_717" />
<definitionArc xlink:type="arc" xlink:arcrole="http://xbrl.org/int/dim/arcrole/domain-member" xlink:from="loc_us-gaap_ProductWarrantyLiabilityLineItems_711" xlink:to="loc_us-gaap_StandardProductWarrantyAccrual_717" use="optional" order="13" />
</definitionLink>
</linkbase>
