Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to require an alternative js file from a npm package without specifiying full node_modules path

I am using the ES2016 import syntax to load the select2 libray from an npm module (via Webpack):

import 'select2';

This works fine and loads the following file from the node_modules directory.

node_modules/select2/dist/js/select2.js

Now within that directory they have a full version of the library which has some extra functionality I need, it is called:

node_modules/select2/dist/js/select2.full.js

Is there a way to import this without providing the full relative path to my node_modules folder?

I tried:

import 'select2.full'

but no luck.

like image 673
benb Avatar asked Dec 16 '15 12:12

benb


1 Answers

Try this:

import 'select2/dist/js/select2.full.js'

I think this is the best you are going to get.

like image 105
chapinkapa Avatar answered Oct 06 '22 15:10

chapinkapa