当前位置: 首页 > news >正文

怎么做领券网站有没有做文创的网站

怎么做领券网站,有没有做文创的网站,网站代码在哪里写,4399游戏网页游戏大全前言 项目中会用到工具库、函数库以及一些跟框架绑定的组件,如果这些基础模块每个项目都实现一套,维护起来那真的头大,你说呢😉 搭建流程 准备工作 创建文件夹myLib、安装Git以及pnpm 目录大概就系这样子: myLib ├…

前言

项目中会用到工具库、函数库以及一些跟框架绑定的组件,如果这些基础模块每个项目都实现一套,维护起来那真的头大,你说呢😉

搭建流程

准备工作

创建文件夹myLib、安装Git以及pnpm

目录大概就系这样子:

myLib
├── .husky
│   ├── commit-msg
│   └── pre-commit
├── packages
│   └── utils
│       ├── lib
│       │   ├── index.cjs.js
│       │   ├── index.esm.js
│       │   └── index.d.ts
│       ├── src
│       │   └── index.ts
│       ├── rollup.config.js
│       ├── tsconfig.json
│       └── package.json
├── .eslintrc.js
├── .prettierrc
├── commitlint.config.js
├── pnpm-workspace.yaml
├── tsconfig.json
└── package.json

配置Typescript

pnpm add -D -w typescript tslib
pnpm tsc --init

tsconfig.json

{
    "files": [],
    "references": [
      { "path": "./packages/utils" }
    ]
  }

 pnpm-workspace.yaml

packages:
  - 'packages/*'

package.json

  "scripts": {
    "postinstall": "husky install",
    "lint": "eslint packages/**/*.{ts,js} --fix"
  }

子包

tsconfig.json配置 

{
  "compilerOptions": {
    "rootDir": "./src",
    "declaration": true,
    "declarationDir": "./lib",
    "emitDeclarationOnly": true,
    "module": "esnext",
    "target": "es6",
    "moduleResolution": "node",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "include": ["src/**/*"]
}

Rollup打包

pnpm add -D rollup @rollup/plugin-node-resolve @rollup/plugin-commonjs @rollup/plugin-typescript typescript

rollup.config.js

import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';

export default {
  input: "src/index.ts",
  output: [
{
    file:"lib/index.cjs.js",
    format:"cjs",
},
{
    file:"lib/index.esm.js",
    format:"esm",
},
  ],
  plugins:[
    resolve(),
    commonjs(),
    typescript()
  ]
};

package.json

  "scripts": {
    "build": "rollup -c"
  } 

git commit 验证

记得用git先初始化下仓库

pnpm add -D -w husky @commitlint/{config-conventional,cli}
pnpm husky install

pnpm dlx husky-init --pm=pnpm

npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'

commitlint.config.js

module.exports = {
  extends: ['@commitlint/config-conventional']
}; 

配置Eslint和Prettier

 pnpm add -D -w eslint prettier eslint-config-prettier eslint-plugin-prettier

eslint.config.js

const path = require('path');
const { ESLint } = require('eslint');
const tsParser = require('@typescript-eslint/parser');
const tsPlugin = require('@typescript-eslint/eslint-plugin');
const prettierPlugin = require('eslint-plugin-prettier');

module.exports = [
  {
    files: ['packages/**/src/**/*.{ts,js}'],
    ignores: ['node_modules'],
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        ecmaVersion: 2020
      },
    },
    plugins: {
      '@typescript-eslint': tsPlugin,
      prettier: prettierPlugin,
    },
    rules: {
      'prettier/prettier': 'error',
      'no-unused-vars': 'off',
      '@typescript-eslint/no-unused-vars': 'warn',
    },
  },
]

.prettierrc

{
    "singleQuote": true,
    "trailingComma": "all",
    "printWidth": 80
  } 

.husky/pre-commit

pnpm run lint 

打包

最后

整体的框框已经搭建起来,把需要的工具、函数和组件写入即可,发布子包到私有仓库即可内部使用啦~

http://www.yayakq.cn/news/870114/

相关文章:

  • 做外贸必看的网站和论坛有哪些个人网站备案流程
  • led外贸网站要怎么做网站
  • 工业电商网站怎么配色西安官网seo收费
  • 西安专业手机网站建设价格建设部网站内装修标准
  • 网站建设上海哪家公司好外包网站制作
  • 横岗做网站公司在深圳注册公司需要什么条件
  • 学校网站建设工作领导小组没学历最吃香的职业
  • 单仁网站建设基础网站建设素材
  • 石家庄在线制作网站如何维护公司网站
  • 网站维护一年一般多少钱?番禺做网站开发
  • 昆明做百度网站电话号码北京做网站需要多少钱
  • 邵阳汽车网站建设页面模板这样选
  • 杭州笕桥网站建设wordpress加目录
  • 庆阳网站设计价格宁波网站商城建设
  • 设计简单的网站网站关键词数量减少
  • 优秀网页设计作品网站北京互联网公司有哪些
  • 电商网站 费用电商网站开发方案模板
  • 惠水网站建设网站推广软件推荐
  • 广东注册公司在哪个网站申请银川网站建设哪家便宜
  • 佛山自己网站建设合肥模板网站建设费用
  • 公司网站管理制定的作用建网站无锡
  • 茂名快速建站模板wordpress 删除 wordpress.org
  • 网站维护目标网站建设服务优势
  • 如何做网站优化并快速提高权重自适应网站开发公司
  • 服务于中小企业建网站管理咨询公司起名字
  • 常德网站建设产品建立wordpress网站吗
  • 网站开发专业有什么工作网站后台分析图怎么做
  • elo机制优化大师官方免费
  • 建瓯做网站的公司企业策划书格式
  • 相册模板seo权威入门教程