简体   繁体   中英

html5 boilerplate: how to add third-party js?

I am not a web developer, and though I believe this question must have a simple answer, I couldn't find it in the documentation, nor online.

I'll use html5 boilerplate to create a very simple app.

I would like to run

npm install an-arbitrary-js-library --save
gulp build

and be able to

import a_random_function from 'an-arbitrary-js-library'

in my js/main.js file.

How can I adapt my HTML5 Boilerplate to add third-party JS libraries to my project automatically?

Just put a script tag with the source referring to your library in the index.html file. I don't know how you orginzed the project but you can copy the file of your third library from node_module to the project js/vendor or any other folders using gulp see from line 69 --> 95 here , this is the way they set jQuery in the project.

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