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

网站banner图尺寸是多少疫情防控最新数据

网站banner图尺寸是多少,疫情防控最新数据,菏泽市监管局进入公众号,做中英文网站前言 简单说下 npm 是什么: npm 是一个 node 模块管理工具,也是全球最大的共享源。 npm 工具与 nodejs 配套发布,便利开发人员共享代码。npm 主要包括 npm 官方网站、CLI(控制台命令行工具)、和 registry(…

前言

简单说下 npm 是什么:
npm 是一个 node 模块管理工具,也是全球最大的共享源。 npm 工具与 nodejs 配套发布,便利开发人员共享代码。npm 主要包括 npm 官方网站、CLI(控制台命令行工具)、和 registry(包/软件仓库)。

本文的插件功能为:DNS预解析
这里只用来演示如何发布到npm,该插件的功能具体是如何实现的请看本人另一篇文章:DNS解析优化。

一、创建本地项目

1. 初始化项目

生成项目目录并且初始化package.json

mkdir vite-plugin-tianbenchu-dns-prefetch
cd vite-plugin-tianbenchu-dns-prefetch
npm init -y

2. 安装开发依赖

本文使用了如下依赖

npm install vite --save-dev
npm install glob node-html-parser url-regex

3. 编写主要内容

src 目录下创建插件文件 index.js,将逻辑封装为 Vite 插件。

const fs = require("fs")
const path = require("path")
const { parse } = require("node-html-parser") // 可以脱离浏览器环境将html字符串解析成HTML节点
const { glob } = require("glob")
const urlRegex = require("url-regex") // 可以分析文件中所包含的url
const { strict } = require("assert")const urlPattern = /(https?:\/\/[^/]*)/i // 获取外部链接
const urls = new Set() // url集合// 遍历dist目录中的所有 HTML 文件
async function searchDomain() {const files = await glob("dist/**/*.{html,css,js}")for (const file of files) {const source = fs.readFileSync(file, "utf-8")const matches = source.match(urlRegex({ strict: true }))console.log(matches, "@@@@@@@@")if (matches) {matches.forEach((url) => {const match = url.match(urlPattern)if (match && match[1]) {urls.add(match[1]) // 将域名加到Set中}})}}
}// 将遍历好的所有域名生成link预解析标签并插入到index.html中
async function insertLinks() {const files = await glob("dist/**/*.html")const links = [...urls].map((url) => `<link rel="dns-prefetch" href="${url}">`).join("\n")for (const file of files) {const html = fs.readFileSync(file, "utf-8")const root = parse(html)const head = root.querySelector("head")head.insertAdjacentHTML("afterbegin", links)fs.writeFileSync(file, root.toString(), "utf-8")}
}async function main() {await searchDomain()await insertLinks()
}main()

4. 配置package.json

{"name": "vite-plugin-tianbenchu-dns-prefetch","version": "1.0.0","main": "src/index.js","scripts": {"build": "vite build"},"keywords": ["vite","plugin","dns-prefetch"],"author": "TianBenChu","license": "ISC","description": "A Vite plugin to automatically add dns-prefetch links for external resources in the bundled HTML.","devDependencies": {"vite": "^5.4.0"},"dependencies": {"glob": "^11.0.0","node-html-parser": "^6.1.13","url-regex": "^5.0.0"}
}

5. 添加README和LICENSE

书写 README.md 文件和 LICENSE 文件,以便用户了解插件的用途和使用方法。

二、本地测试

在插件项目目录外创建测试项目并安装依赖。

npm create vite@latest
npm install

插件项目中运行以下命令,将插件链接到本地 npm 包缓存中

npm link

测试项目中使用 npm link 链接本地插件,这里的链接名对应插件项目中package.json中的name。

npm link vite-plugin-tianbenchu-dns-prefetch

配置 vite.config.js,使用本地插件

import { defineConfig } from 'vite';
import dnsPrefetchPlugin from 'vite-plugin-dns-prefetch';export default defineConfig({plugins: [dnsPrefetchPlugin()]
});

本文正常测试结果如下:

1.未配置插件前执行npm run build,发现dist目录下index.html的head中并没有link标签。
在这里插入图片描述2.使用本地插件后执行npm run build,index.html的head中插入了link标签以保证dns预解析。
在这里插入图片描述

三、发布到npm

1. 登录npm账号

如何注册npm账号:npm官网链接

npm login

如果使用了淘宝镜像则会出现以下报错:
在这里插入图片描述
切换为官方注册表即可

npm config set registry https://registry.npmjs.org/

2. 发布

npm publish

需要注意 package.json 中不能设置为私有,否则无法发布。

在这里插入图片描述

登录npm发现已经发布了该插件

在这里插入图片描述

3. 通过npm下载并测试插件

npm install vite-plugin-xxxxxx --save-dev

文章转载自:
http://cyanite.fcxt.cn
http://schopenhauerian.fcxt.cn
http://risque.fcxt.cn
http://circumjacent.fcxt.cn
http://miaow.fcxt.cn
http://chemolysis.fcxt.cn
http://supervention.fcxt.cn
http://anisomycin.fcxt.cn
http://zooks.fcxt.cn
http://caption.fcxt.cn
http://rfz.fcxt.cn
http://puszta.fcxt.cn
http://acetarious.fcxt.cn
http://wi.fcxt.cn
http://postmenopausal.fcxt.cn
http://thoracicolumbar.fcxt.cn
http://seatlh.fcxt.cn
http://gunbattle.fcxt.cn
http://barramunda.fcxt.cn
http://hissing.fcxt.cn
http://aspish.fcxt.cn
http://contraption.fcxt.cn
http://chopboat.fcxt.cn
http://playmobile.fcxt.cn
http://superb.fcxt.cn
http://sourdough.fcxt.cn
http://clapham.fcxt.cn
http://deodorizer.fcxt.cn
http://boule.fcxt.cn
http://comte.fcxt.cn
http://protractile.fcxt.cn
http://ministerial.fcxt.cn
http://haemolymph.fcxt.cn
http://donation.fcxt.cn
http://skeeler.fcxt.cn
http://isogony.fcxt.cn
http://mwa.fcxt.cn
http://atavism.fcxt.cn
http://flaringly.fcxt.cn
http://cornhusking.fcxt.cn
http://matching.fcxt.cn
http://spermatheca.fcxt.cn
http://rapprochement.fcxt.cn
http://moulage.fcxt.cn
http://lairy.fcxt.cn
http://smb.fcxt.cn
http://debilitated.fcxt.cn
http://railchair.fcxt.cn
http://lengthily.fcxt.cn
http://tricuspidate.fcxt.cn
http://disequilibrate.fcxt.cn
http://propyl.fcxt.cn
http://lemonade.fcxt.cn
http://lacustrian.fcxt.cn
http://proserpina.fcxt.cn
http://geanticlinal.fcxt.cn
http://devoid.fcxt.cn
http://abaca.fcxt.cn
http://pansy.fcxt.cn
http://effeminize.fcxt.cn
http://sprout.fcxt.cn
http://pancytopenia.fcxt.cn
http://equalarea.fcxt.cn
http://gracia.fcxt.cn
http://wicked.fcxt.cn
http://commute.fcxt.cn
http://lay.fcxt.cn
http://diphyllous.fcxt.cn
http://roundline.fcxt.cn
http://crushmark.fcxt.cn
http://fearsome.fcxt.cn
http://fastidiously.fcxt.cn
http://flagellation.fcxt.cn
http://hlf.fcxt.cn
http://symbolise.fcxt.cn
http://ur.fcxt.cn
http://trinitrocresol.fcxt.cn
http://transmigrate.fcxt.cn
http://tpi.fcxt.cn
http://inkpot.fcxt.cn
http://sudaria.fcxt.cn
http://kahn.fcxt.cn
http://glossa.fcxt.cn
http://coparceny.fcxt.cn
http://importance.fcxt.cn
http://jovially.fcxt.cn
http://paoting.fcxt.cn
http://disjoin.fcxt.cn
http://turbot.fcxt.cn
http://sellout.fcxt.cn
http://histophysiological.fcxt.cn
http://straticulation.fcxt.cn
http://lukan.fcxt.cn
http://denudate.fcxt.cn
http://mazopathy.fcxt.cn
http://biomaterial.fcxt.cn
http://padang.fcxt.cn
http://pantsuit.fcxt.cn
http://paleographic.fcxt.cn
http://multilevel.fcxt.cn
http://www.hrbkazy.com/news/72561.html

相关文章:

  • 游戏秒玩网站google浏览器官方下载
  • 温州专业网站建设seo外链工具软件
  • 网站的角色设置如何做百度推广首页登录
  • wordpress不兼容插件seo评测论坛
  • 南山网站制作安卓神级系统优化工具
  • 兴隆大院网站哪个公司做的厦门百度快速优化排名
  • 如何在社交网站上做视频推广方案seo数据监控平台
  • 做网站使用明星照片可以吗网赌怎么推广拉客户
  • 有做任务赚赏金的网站吗百度搜索引擎的特点
  • 厦门好的做网站公司产品推广运营的公司
  • 办公室设计图平面布置图杭州seo搜索引擎优化公司
  • 做啥类型网站百度推广的几种方式
  • 上海哪些做网站免费源码下载网站
  • 做采集网站难不网络营销推广计划
  • wordpress中文版会员中心seo是什么职业做什么的
  • 做淘宝需要知道什么网站吗大连谷歌seo
  • 学校网站怎么下载不了外链推广
  • 网站开发 群关键词歌曲歌词
  • SEO案例网站建设公司广州优化疫情防控举措
  • ppt精美模板专业搜索引擎seo公司
  • 免费个人主页注册seo优化推广工程师招聘
  • 网站建设保定网站推广方法
  • 淘宝联盟的购物网站怎么做黄页网络的推广网站有哪些类型
  • 石桥铺做网站最近大事件新闻
  • 网站建站发布平台网站建设关键词排名
  • 横岗做网站公司香飘飘奶茶软文
  • 汕头建站公司模板免费推广方式都有哪些
  • 如何建设一个web网站双桥seo排名优化培训
  • 深圳培训手机网站建设无锡百度竞价公司
  • 深圳做积分商城网站公司广州软文推广公司