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?
-
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.Abir Taheer– Abir Taheer2022-02-15 23:44:35 +00:00Commented 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 againKevin Greetham– Kevin Greetham2022-02-15 23:50:12 +00:00Commented Feb 15, 2022 at 23:50
Add a comment
|
1 Answer
Yes. For example, Bootstrap has an NPM package with their CSS in it.
14 Comments
mstephen19
No. But you can create project templates with npx, kind of like create-react-app does.
Kevin Greetham
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?
Kevin Greetham
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.
Kevin Greetham
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!
Kevin Greetham
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!
|