package.json
{
"name": "库名称",
每次 npm publish 之前要先修改版本号
"version": "1.0.0",
项目描述
"description": "",
入口文件
"main": "./dist/uu-utils.js",
仓库地址
"repository": "https://github.com/",
脚本
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:watch": "webpack --watch"
},
关键词
"keywords": [
"array",
"object",
"function",
"string",
"axios",
"promise",
"event-bus"
],
作者名称
"author": "Rck",
开源协议
"license": "ISC",
"dependencies": {},
"devDependencies": {
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
}
}
webpack.config.js
const path = require('path');
module.exports = {
开发模式
mode: 'development',
可以进行压缩,方便引入
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'uu-utils.min.js',
library: 'uuUtils',
libraryTarget: 'umd'
},
externals: {
}
}
上传 npm
- 注册 npm 账号
- 终端登录 npm login 输入账号密码邮箱
- 推到 npm 仓库 npm publish
上传到 github
- 创建 github 仓库
- git init
- git add .
- git commit -m ‘first’
- git remote add origin 改变git源
- git push origin master