1.0.1 • Published 2 years ago

@licq/site-cdn v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@licq/site-cdn

主要用于静态站点的静态资源走cdn,比如hexo、vuepress

NPM version NPM downloads

安装

npm i --save-dev @licq/site-cdn

API

siteCdn

替换vuepresshexo等构建产物里html的静态资源路径, 拼接cdn

Returns: undefined
Since: v1.0.0

ParamTypeDescription
distfs.PathLike构建产物绝对路径
baseString静态资源前缀 eg: '/''/blog/'
cdnStringcdn地址 eg: 'https://demo.cdn.com/blog/'

Example

const siteCdn = require('@licq/site-cdn')
siteCdn('/Users/xxx/path/to/vuepress/dist', '/blog/', 'https://demo.cdn.com/')
//==> undefined

Example

// eg: xxx.html ===>

// - <script type="module" src="/blog/assets/app.7bfa9b79.js" defer></script>
// + <script type="module" src="https://demo.cdn.com/blog/assets/app.7bfa9b79.js" defer></script>

// - <link rel="stylesheet" href="/blog/assets/style.c2b7e6ed.css">
// + <link rel="stylesheet" href="https://demo.cdn.com/blog/assets/style.c2b7e6ed.css">

// - <img class="logo" src="/blog/assets/ost-hourse.png" alt="Ostwindli's Asenal">
// + <img class="logo" src="https://demo.cdn.com/blog/assets/ost-hourse.png" alt="Ostwindli's Asenal">
1.0.1

2 years ago

1.0.0

2 years ago