0.1.2 • Published 1 year ago

build-plugin-js-assets-local v0.1.2

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year ago

build-plugin-js-assets-local

基于 build-scripts 扩展插件,用于在 build 时将 js 中 cdn 图片下载到本地并替换为 PublicPath 的路径。

例如 js 中应用/使用了 cdn 图片:https://img.alicdn.com/imgextra/i2/tps-360-96.png 会被替换为:${PublicPath}/assets/imgextra/i2/tps-360-96.png

Install

npm i build-plugin-js-assets-local@^0.1.0 -D

Usage

  • build.config.js 配置文件
module.exports = {
  plugins: [
    [
      "build-plugin-js-assets-local",
      {
        enabled: true, // 控制开启,可不配
        assetsPath: "assets", // 下载资源目录,可不配
        removeManifest: false, // 是否删除manifest文件,可不配
        manifestFilePath: "manifest.json", // manifest文件路径,可不配
        activeInDev: false, // 是否在开发阶段生效,默认关闭
        matchReg: `(https?:)?\/\/(img|o|g|gw|dev\.g|dev\.o|at)\.alicdn\.com\/(imgextra|t)\/.*?\.(png|gif|jpg|jpeg|svg|js)`, // 正则匹配cdn图片和cdn js,默认可不配
      },
    ],
  ],
};
  • package.json scripts 配置
{
  "scripts": {
    "build": "icejs build --config build.config.js"
  }
}
0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago