Skip to content
Advertisement

Is there a way to integrate stencil components into frameworks locally without publishing to NPM?

I am currently testing stencil js. For now I want to write stencil components and include them within a VUE/React project. The official website of stencil already shows how to integrate them within a framework (https://stenciljs.com/docs/overview). But they assume that your own stencil component library has already been published to npm.

Is there a way to integrate stencil components locally into a framework to test them without publishing them first?

Advertisement

Answer

Yes, you can use npm-link for that.

cd my-component-lib
npm link

cd ../my-app
npm link my-component-lib # or whatever you have named the project in package.json

If you have any problems with that (e. g. with paths not resolving properly), you can also try to pack your package and install the packed version instead, using npm-pack:

cd my-component-lib
npm pack

cd ../my-app
npm install ../my-component-lib/my-component-lib-1.0.0.tgz

Linking is preferable though because changes to your component library will be reflected immediately (after a rebuild), whereas with packing you’d have to re-pack and re-install it after every change to your lib.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement