3

I’ve looked everywhere for this and cannot find a definitive answer. I’ve just started on the node package manager. If publishing a package for the community can it consist of html and css or is it purely for packages written in JavaScript?

2
  • Are you allowed to include it in the project files? Sure. There still needs to be a javascript file that is defined as the export otherwise your package won't really do anything. Commented Feb 15, 2022 at 23:44
  • Thanks Abir, if I installed the package into another project via the cli would the html page be created on my new project when showing up in my package.json file? Thanks again Commented Feb 15, 2022 at 23:50

1 Answer 1

2

Yes. For example, Bootstrap has an NPM package with their CSS in it.

https://www.npmjs.com/package/bootstrap

Sign up to request clarification or add additional context in comments.

14 Comments

No. But you can create project templates with npx, kind of like create-react-app does.
How about if I exported a package which contained Js code creating new Dom elements and another person installed the package, would it then show up in their html page if the package was required in the project JS page?
Yes. I’ve been using react and vanilla is. I just want to get a better understanding of the inner workings around npm. This massively helped. Thanks.
I’ve looked further into this. Yes you definitely could. When we export the functions from Js file with these capabilities it is open to use in our project. If you want the exported functions to create domElements then that’s exactly what it will do! You could set the classNames from within the exported function or pass the className into the function as an argument if you wanted to extend a html element that already exists in your html page! The second way would allow you to modify already existing elements!
But you wouldn’t export an html page. As it would appear in the node modules folder. You’d call your expected functions from inside your main Js working folder and manipulate the Dom from their!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.