Skip to content

5.x: unique content sources for each build environmentΒ #1385

@cossssmin

Description

@cossssmin

Because we now use globs for content sources (similar to Tailwind CSS v3), the environment config merging strategy falls short in some cases. For example, consider the following setup:

config.js

export default {
  build: {
    content: ['src/templates/**/*.html'],
  }
}

config.sendgrid.js

export default {
  build: {
    content: ['src/templates/sendgrid/**/*.html'],
  }
}

Normally, when we run maizzle build sendgrid we'd expect it to just build our Sendgrid templates.

However, if src/templates also contains some assets folders, like say images, then because of the config merging the src/images folder will also be considered a templates source.

That would work, as in the folder would just get copied over and the build would succeed.

However, we'd get a build output folder with this structure:

build_sendgrid
|-- sendgrid
|-- images

When in fact we just want this:

build_sendgrid
|-- sendgrid

Solution

To fix this we could try to not merge the build.content keys, effectively overriding the one you have in config.js.

This would be a breaking change if you're relying on the merging strategy when building for production, i.e. you need templates defined in build.content from config.js and are just adding sources to it - in this case you'd need to always define all of your content sources in each config file.

Note: I ran into this a few times while working on real life projects with v5 beta, but I might be biased in the way I use it, so leaving this open for now - input is appreciated πŸ‘

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions