From 8149dd50cc0b7c1d30ec72b48bcf8f01f1d519d4 Mon Sep 17 00:00:00 2001 From: xyf-mac Date: Fri, 2 Apr 2021 21:49:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/plugins/chrome-manifest.js | 45 ++++++++++++++++++++++++++++++ source/public/favicon.ico | Bin 0 -> 4286 bytes source/public/index.html | 17 +++++++++++ 3 files changed, 62 insertions(+) create mode 100644 source/plugins/chrome-manifest.js create mode 100644 source/public/favicon.ico create mode 100644 source/public/index.html diff --git a/source/plugins/chrome-manifest.js b/source/plugins/chrome-manifest.js new file mode 100644 index 0000000..d1e8076 --- /dev/null +++ b/source/plugins/chrome-manifest.js @@ -0,0 +1,45 @@ +const Fs = require("fs"); +const Path = require("path"); +const FsExtra = require("fs-extra"); + +class ChromeManifest { + constructor(options) { + this.options = options; + } + + apply(compiler) { + compiler.plugin("done", function (compilation, callback) { + const {manifest} = this.options; + if (manifest) { + if (Fs.existsSync(manifest)) { + // 生成manifest.json + let data = require(manifest); + let distPath = compilation.compilation.options.output.path; + let outFile = Path.join(distPath, "manifest.json"); + Fs.writeFileSync(outFile, JSON.stringify(data, null, 4)); + console.log(`生成manifest文件: ${outFile}`); + + // 复制图片 + const manifestDir = Path.dirname(manifest); + if (data.icons) { + for (let key in data.icons) { + let icon = data.icons[key]; + let iconPath = Path.join(manifestDir, icon); + if (Fs.existsSync(iconPath)) { + FsExtra.copySync(iconPath, Path.join(distPath, icon), {overwrite: true}); + console.log(`copy res: ${icon}`); + } + } + } + } else { + console.error(`manifest文件不存在:${manifest}`); + } + } else { + console.log("缺少插件的manifest信息"); + } + }.bind(this)); + + } +} + +module.exports = ChromeManifest; diff --git a/source/public/favicon.ico b/source/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/source/public/index.html b/source/public/index.html new file mode 100644 index 0000000..3e5a139 --- /dev/null +++ b/source/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + <%= htmlWebpackPlugin.options.title %> + + + +
+ + +