Understanding persist_to_workspace

Im struggling here and hope someone can help me out. I just dont get how the root and path attributes are working together with persist_to_workspace.

I do the following:

  - checkout
  - run: rm -rf .git
  - persist_to_workspace:
      root: /root
        - project

Later I do:

   at: ~/

This works. In my first job I have the workspace at /home/circleci/project with my everything I need.
Now I build my frontend which gives me a folder at /home/circleci/project/frontend/build.

The only thing I want to do now is persisting this folder at the same path so that its available in the next job who attachs the workspace at ~/project/frontend/build. But however I do the persist_to_workspace the build folder always is at the same level of project.

-> project frontend/build

instead of

-> project/frontend/build

How can I do that?

After wasting 2 hours yesterday…I had it 2mins after posting here…

I did this

  - persist_to_workspace:
      root: ~/
      paths: project/frontend/build

And it seems to save the workspace like I want to.