#Bundle an npm package without importing?

1 messages · Page 1 of 1 (latest)

rich oracle
#

im kinda confused, what exactly are you trying to do?

able to import the jquery only from SOME of my static HTML files.

can you explain a bit more, didnt understand this

noble tundra
#

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

last flint
#

I want vite build to copy the ./node_modules/jquery/dist folder into my static-vite folder.

noble tundra
#

you just import jquery in any file that uses it, so it gets bundled

last flint
#

I know that is the recommended way. However, I use Django and there it doesn't work this way

rich oracle
#

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?

noble tundra
last flint
#

@noble tundra Thanks for your recommendation. However, I'm not interested in a different solution than what I asked.

noble tundra
#

okay but now we're getting into xy problem territory

#

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?

last flint
#

It's not an XY Problem, it's a direct question.

noble tundra