Single codebase, dynamic slicemachine

Hi Guys, i hope you well.

I'm creating a single codebase and i want to use slicemachine in it. Now, i have a doubt... is there any way to use only one codebase to multiple slicemachine?

In the file: sm.json, we have the apiEndpoint property. I thought about do something like that:

{
  "apiEndpoint": `https://{process.env.PRISMIC_PROJECT}.cdn.prismic.io/api/v2`,
  "libraries": [
    "@/src/components/slices"
  ],
  "_latest": "0.1.0",
  "storybook": "http://localhost:8888"
}

So with this, i could run:

PRISMIC_PROJECT=my-prismic yarn start
OR
PRISMIC_PROJECT=my-prismic-two yarn start

Is possible do something like that?

@Phil can you help me with this?

Hey @telco.pls,

Can you say more about your use case? Are you going to duplicate the codebase for multiple projects, or do you want to switch between repositories in one app? What is this for?

Sam

Hey @samlittlefair .

I want to swtich between repositories in one app (codebase).

is it possible?

Thanks.

Hi @telco.pls,

I've never seen anyone try that before. Why do you want to switch between repositories in one app? (If I understand your app better, I can give better suggestions.)

Sam

Hi @samlittlefair .

We want a single codebase for multiple websites. We have done it before, because our codebase is generic and we need only to change the prismic api. So we do it, based on a environment variable.

Something like: https://${PRISMIC_PROJECT}.cdn.prismic.io/api/v2

But, we can't do this with slicemachine. Because the slicemachine create a sm.json file and there's an apiEndpoint.

Can you understand now?

Thank you so much.

Hey @telco.pls,

The main benefit of Slice Machine is for modelling content in your Prismic repo. If what you're describing is possible (though I'm not sure it is; I'll check with my team), you would have to manage your Custom Types and Slices separately for each repo. That means if you change your Custom Types or Slices, you would have to change the environment variable to push the changes to each repo. Is that what you have in mind?

Sam

Hi @telco.pls,

Env variables and Slice Machine have previously been discussed here:

Although, it's not possible at the minute, but tracked as a feature request.

(This is something the team really wants to implement but it’s not in the pipe right now. If you have a certain scripted flow, you can rewrite the manifest whenever necessary of course.)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.