Vote count: 0
I am tryng to use npm libraries in browsers. Taking the npm library uniq as an example, at the moment, we need first to write the code that locally uses uniq
:
// main.js
var unique = require('uniq');
var data = [1, 2, 2, 3, 4, 5, 5, 5, 6];
console.log(unique(data));
Then, we need to run browserify
in a console:
browserify main.js -o bundle.js
As a result, we could use it in a html file:
My question is, whether it is possible to browserify a library such that any code inside the "script" tag could use it. For example, in the html part, I may want to write
If it is possible, we don't have to browserify the code (in a console) every time we change the code.
Does anyone know if it is possible by browserify or any other tools?
asked 29 secs ago
Browserify a library rather than a file
Aucun commentaire:
Enregistrer un commentaire