Can you import dependencies from your other plunks

2019-06-03 10:16发布

Is it possible to import my other plunker as a library in a new plunker?

Say, I've built a few AngularJS directives in a plunker. Can I reuse them in my other plunkers?

标签: plunker
1条回答
2楼-- · 2019-06-03 11:09

You absolutely can refer from one plunk to another, but the mechanics to do so are not very well exposed. Historically, Plunker didn't expose this to users by design.

In future versions, Plunks will be publishable as semver versioned packages to the package manager and this sort of thing will automatically be wired up for you.

To use the type of setup you propose in Plunker today, you can:

  1. Create your new directive as its own Plunk and make sure that it is saved. It doesn't matter if it is public or private.
  2. Note this new plunk's id as its latest saved version will be available at http://run.plnkr.co/plunks/<plunkId>/[filename.ext]
  3. In your 2nd plunk, you can either:
    • Add the directive to the package catalogue using the above url and then add that new package to your plunk; or
    • Add the directive script directly to your index.html via a typical <script src="<url>"></script> tag.

I think that better search capabilities (already in preview at http://explore.plunker.co) and this mechanism for publishing versioned plunks to the catalogue will allow some really cool and efficient workflows for the next generation of online prototyping.

查看更多
登录 后发表回答