How to delete custom slices using CLI (SliceMachine)?

Hello Community,

Is there a command to delete custom slices using the CLI? I ran prismic sm --help but did not see that as an option. Or is there a way to do this in the SliceMachine and/or Storybook UI?

Else, I think I managed to delete manually by deleting the slice folder + import from the slice/index.js — anything else I should consider?

Cheers,
Patrick

Hello Patrick,

Thanks for posting this question to us.

There is no command yet to delete a slice. You need to delete it manually by deleting the folder. I understand how important it is to delete a created slice, but Slice-machine is still in beta, and our team is working on it to improve its feature.

Let me know if you have further questions.

Priyanka

Hi Priyanka,

thanks for the fast response. I totally understand about things being in beta, thought I'd just double check. Will go manual till further notice :slight_smile:

Cheers,
Patrick

1 Like

Hi Priyanka,

I have few other questions regarding this issue. As described, I managed to delete a custom slice manually by deleting/updating the following files from my local folder:

  • deleted: .slicemachine/assets/slices/MySliceName/preview.png
  • deleted: slices/MySliceName/index.stories.js
  • deleted: slices/MySliceName/index.vue
  • deleted: slices/MySliceName/mocks.json
  • deleted: slices/MySliceName/model.json
  • deleted: slices/MySliceName/preview.png
  • updated: slices/index.js (removed 'export { default as MySliceName } from "./MySliceName";'

Since deleting these files, the slice is no longer visible in my StoryBook or SliceMachine UI (as expected). However, it still shows up inside of my editor in Prismic under shared slices (see screenshot). Is there another step I need to do to remove this from Prismic? (FYI: I did also try clearing the browser cache/opening in private mode (Chrome), but the result was the same).

On a similar note:

  • screenshots do not seem to update after the first push to Prismic (see screen)
  • it seems the same issues prevent me from renaming any custom slices, i.e., changes can be made locally. However they don't update in Prismic.

Let me know if you would prefer me to raise add'l issues for the two above-mentioned.

Hey Patrick,

This is all you need to do. But once the slices have pushed to the Prismic UI, they will always be available in the shared tab even though you have deleted them from the code. I'll discuss this with my dev team to include this in their future improvements and will let you know what they think.

Thanks,

Priyanka

1 Like

Hello Patrick,

I have discussed this with the team and this is something planned for future improvements yes! Being able to fully delete a slice, renaming it.

There will be a custom-type API where you will be able to update, delete shared slices, and documentation will release soon. You can check the progress here.

Thanks,

Priyanka

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

Hi Everyone,

The team has planned to work in the current sprint to enable deletions and updates etc.

Although I've discussed a workaround for the moment here:

I'm also dealing with the preview images not being updated over in this thread:

Let me know if you have any questions.

Thanks.

We pushed the update, if you update to slice-machine-ui 0.0.45, it should allow you to update the images.