0.1.1 • Published 6 years ago
huypq-angular-datepicker v0.1.1
Step to create and publish new angular 2 package to npmjs.com (reference https://github.com/jvandemo/generator-angular2-library)
- Setup environment:
Install
npm
https://nodejs.org/enInstall
angular
npm install -g @angular/cli
- Install
gulp
:
npm install -g gulp
npm install -g gulp-cli
- If
node_modules
in root folder (angular), run:
npm install
Copy
lib-name
folder, rename toyour-lib-name
Replace
lib-name
text in 4 file toyour-lib-name
as below:
gulpfile.js
(2 hits) - Line 128: name: 'lib-name', - Line 136: .pipe(rename('lib-name.umd.js'))package.json
(1 hit) - Line 2: "name": "lib-name",src\package.json
(5 hits) - Line 2: "name": "lib-name", - Line 19: "main": "lib-name.umd.js", - Line 20: "module": "lib-name.js", - Line 21: "jsnext:main": "lib-name.js", - Line 22: "typings": "lib-name.d.ts",src\tsconfig.es5.json
(2 hits) - Line 24: "flatModuleOutFile": "lib-name.js", - Line 25: "flatModuleId": "lib-name"
Create symbolic link to
node_modules
:- open cmd (with Administrator previllage if needed), cd to
your-lib-name
- run mklink /d node_modules ..\node_modules
- open cmd (with Administrator previllage if needed), cd to
Replace
src
folder content to your lib content, but must keep 3 config file (.json):- Can replace:
-
h-sample.component.html
-h-sample.component.css
-h-sample.component.ts
-index.ts
- Must keep:
-
package.json
-tsconfig.es5.json
-tsconfig.spec.json
- Can replace:
-
Build lib:
nmp run build
- Publish to nmpjs.com: (need increase version package.json before publish)
npm publish dist