#Bundle an npm package without importing?
1 messages · Page 1 of 1 (latest)
I want to be able to import the jquery only from SOME of my static HTML files.
how about you just import it from any file that you need jquery
I want vite build to copy the ./node_modules/jquery/dist folder into my static-vite folder.
my proposal is you don't
you just import jquery in any file that uses it, so it gets bundled
I know that is the recommended way. However, I use Django and there it doesn't work this way
I think you can pass in the path to the node_modules to this static copy plugin https://www.npmjs.com/package/vite-plugin-static-copy (or just do a cp ./path/from ./path/to but breaks on windows and all that)
also to clarify, how are you intending to use the stuff copied to the folder?
I am not aware of how jquery's npm package looks like but are you sure you can use jquery from those files?
I use Django and there it doesn't work this way
the backend server you use is irrelevant as long as it can serve static files
@noble tundra Thanks for your recommendation. However, I'm not interested in a different solution than what I asked.
okay but now we're getting into xy problem territory
Asking about your attempted solution rather than your actual problem
it would be much better if you explained why you want to do this
is there a library that uses jquery that you use? do you just want to use jquery in your own scripts? why don't you want to import it in main.js?
It's not an XY Problem, it's a direct question.
well you haven't explained your motivation and seem to be stubborn about not explaining it, which makes it harder for us to find the best actual solution