简体   繁体   中英

Using non-npm packages with npm

i want to use some packages which are not on npm, but my application is using npm and webpack for bundling, how can i use those packages in my application. These packages does not have package.json file.

I do not want to use separate script tags for including them in my webpage, instead i want npm and webpack to bundle them with my other code. Is it possible?

You will have to download your packages into your project. Say,

src/vendor/colorlib is your directory:

// src/vendor/colorlib
import './../vendor/colorlib';

Change webpack.config.js to include your vendor library

// webpack.config.js
const path = require('path');

// web.config.js
resolve: {
  alias: {
    vendor: path.resolve(__dirname, 'vendor')
  }
},

// src/foo.js
import 'vendor/colorlib';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM