用户名,密码,邮箱后面发布会用到 注册完需要验证邮箱 会发送邮件至你注册的邮箱 按指示完成验证即可
mkdir package
cd package
npm init -y
后续可在 package.json 文件中增加更改配置
npm i eslint
eslint --init
npm install @commitlint/cli @commitlint/config-conventional husky --save-dev
module.exports = {
extends: ['@commitlint/config-conventional']
}
// package.json
"husky": {
"hooks": {
"pre-commit": "eslint src --fix --ext .js",
"commit-msg": "commitlint -e"
}
}
npm install webpack webpack-cli --save-dev
npm install @babel/core @babel/preset-env babel-loader @babel/plugin-transform-runtime @babel/runtime-corejs3 --save-dev
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
library: 'package',
libraryTarget: 'umd',
},
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
}]
}
}
{
"presets": [
["@babel/preset-env"]
],
"plugins": [
[
"@babel/plugin-transform-runtime", {
"corejs": 3
}
]
]
}
新建 src 目录 创建index.js
npm login
依次输入用户名 密码 邮箱
npm publish
包名不能重复并合法 使用官方源 npm config set registry http://registry.npmjs.org 注册npm的邮箱需要验证