#Include/exclude pages from build?

4 messages · Page 1 of 1 (latest)

torpid portal
#

Is there a way to include and exclude pages from the build? I'm aware of https://docs.astro.build/en/core-concepts/routing/#excluding-pages, but that doesn't meet my needs. I want to have two builds, each of which would process different folders under src/pages. So the pages from the first build would be excluded from the second build and vice versa. (Why do I want to do this? To work around this bug: https://github.com/withastro/astro/issues/6247)

The only way I'm seeing of doing this is to move the second set of pages to a folder other than src and invoking the second build with the srcDir option (https://docs.astro.build/en/reference/configuration-reference/#srcdir). I'd rather not move a bunch of files around.

opaque jacinth
#

Hi, any progress on this issue? I also ran into this problem, my pages folder is a submodule of git and I am not able to change the content, but I need to exclude some folders to generate routes.

severe garden
#

+1 for excluding Astro pages via some variable. I have a page for developers that I don't want to have included in our production environment, but it should be there in other testing envs.

hot berry
#

I do go with private routes prefixing them with _ (Astro feature), but using it together with custom integration injectPrivateRoutes.mjs:

export default ({ enabled, routes }) => ({
  name: 'inject-private-routes',
  hooks: {
    'astro:config:setup': ({ injectRoute }) => {
      if (enabled) {
        routes.forEach(({ pattern, entryPoint }) => {
          injectRoute({
            pattern,
            entryPoint,
          });
        });
      }
    },
  },
});

with a usage of:

export default defineConfig({
  ...
  integrations: [
    injectPrivateRoutes({
      enabled: !isProdOrStageBuild, // this can be configured according business needs
      routes: [
        {
          pattern: '/[locale]/dev',
          entryPoint: './src/pages/[locale]/_dev.astro',
        },
      ],
    }),
});