0.1.4 • Published 5 years ago
open-source-template-2021 v0.1.4
External js library
With private repository in git, by publishing to NPM, we will be able to use the js library in web browser and in node js project.
How to create
run
npm initin project directoryIt will ask for project name and other info. Respond accordingly.
Add below dependencies in package.json.
"dependencies": {
"@babel/polyfill": "7.12.1"
},
"devDependencies": {
"@babel/cli": "7.12.10",
"@babel/core": "7.12.10",
"@babel/plugin-proposal-class-properties": "7.12.1",
"@babel/preset-env": "7.12.11",
"@babel/register": "7.12.10",
"babelify": "10.0.0",
"browserify": "17.0.0",
"chai": "4.2.0",
"gulp": "^4.0.0",
"gulp-babel": "8.0.0",
"gulp-concat": "2.6.1",
"gulp-mocha": "7.0.2",
"gulp-plumber": "^1.2.1",
"gulp-sourcemaps": "3.0.0",
"mocha": "8.2.1",
"vinyl-source-stream": "2.0.0"
}- Run
npm install Run
npm install -g gulpWe will use gulp as our task runner, so it needs to be installed globally.
Add the src -
mainandtest.- Add gulpfile.js - write the test - build - browserify scripts.
- Run
gulpOutput will be in the directory defined ingulpfile.js
Add GIT
git init
git remote add origin origin-url###Build and publish
gulp
git add .
git commit -m "test added"
git tag "0.1.3"
git push origin master
git push --tags
npm publishUSAGE
https://www.unpkg.com/pckgname@version/path-to-output-dir
End