maizzle / framework

Quickly build HTML emails with Tailwind CSS.
https://maizzle.com
MIT License
1.24k stars 49 forks source link

fix: serve build templates array with nested directory structure #1183

Closed obiwan00 closed 8 months ago

obiwan00 commented 8 months ago

I would like to fix an issue related to serving build templates with a nested directory structure.

Issue Description

The current implementation fails when dealing with templates organized in nested directories and configured with templates as Array, during the serve command rebuild process of nested template files.

Proposed fix

I propose to make the matching of a file to a template source using String.prototype.includes() function instead of strict equality (===).

Example:

// Simplified monorepo directory structure with shared packages for different projects
├───projects
│   ├───project-1
│   │   └───maizzle // <-- config.js
│   │       └───templates
│   │           ├───p1-1
│   │           └───p1-2
│   └───project-2
└───shared-packages
    ├───package-A
    │   └───templates  // ✅ 'serve' rebuild of files from 'shared-packages/package-A/templates/*.html' is OK
    │       └───a // ❌ 'serve' rebuild of nested files from 'shared-packages/package-A/templates/a/**/*.html' is failed
    │           ├───a1 // ❌
    │           └───a2 // ❌
    └───package-B
        └───templates
// Shortened expected output result
├───p1-1
├───p1-2
└───package-A
    └───a
        ├───a1
        └───a2
// config.js file
module.exports = {
  build: {
    templates: [
      {
        source: 'src/templates',
        destination: {
          path: destinationPath,
        },
      },
      {
        source: '../../../shared-packages/package-A/templates',
        destination: {
          path: `${destinationPath}/package-A`,
        },
      },
     // ...
    ],
  }   
}

Thank you for the great work!

cossssmin commented 8 months ago

Hey there, thanks for working on this! Will try to go over both PRs this week 👍

cossssmin commented 8 months ago

Thanks!

obiwan00 commented 8 months ago

Thank you. Do you have plans for releasing a new patch version?

cossssmin commented 8 months ago

Yes, let's get your other PR tested and merged in first :) there are a few dependency updates waiting too, will release a patch to include them all 👍

cossssmin commented 8 months ago

@obiwan00 https://github.com/maizzle/framework/releases/tag/v4.8.0