mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-19 16:38:41 +00:00
调整
This commit is contained in:
parent
2fcb4ff2d1
commit
8149dd50cc
45
source/plugins/chrome-manifest.js
Normal file
45
source/plugins/chrome-manifest.js
Normal file
@ -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;
|
BIN
source/public/favicon.ico
Normal file
BIN
source/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
17
source/public/index.html
Normal file
17
source/public/index.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||||
|
</noscript>
|
||||||
|
<div id="app"></div>
|
||||||
|
<!-- built files will be auto injected -->
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user