0 Star 1 Fork 0

lizeping/cesium-heatmap-es6

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webapck-plugin-copy.js 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
pczheng 提交于 2022-02-16 00:24 . modify script
const fs = require("fs-extra");
let paths = []
class CopyDirWebpackPlugin {
constructor(options) {
if (!Array.isArray(options)) {
options = [options];
}
this.options = options;
}
getOptions(skipts) {
if (skipts) {
return {
filter: (src) => {
if (fs.lstatSync(src).isDirectory()) {
return true;
} else {
paths.push(src)
return src.indexOf(".ts") < 0
}
}
}
} else {
return {}
}
}
apply(compiler) {
const opts = this.options;
compiler.hooks.done.tap(
'Copy Plugin',
(
stats /* stats is passed as an argument when done hook is tapped. */
) => {
opts.forEach(opt => {
fs.copy(
opt.from,
opt.to,
this.getOptions(opt.skipts)
).then(res => {
console.log(`完成 copy ${opt.from} to ${opt.to} ${JSON.stringify(res)}`);
if (opt.skipts) {
//把打包生成js删除
paths.forEach((src) => {
if (src.indexOf(".js") > -1) {
//源码为js的跳过
let find = false
if (opt.skipjs) {
find = opt.skipjs.find((str) => {
return src.indexOf(str) > -1
})
}
if (!find)
fs.remove(src, err => {
if (err) return console.error(err)
console.log(src, 'remove success!')
})
}
})
paths = []
}
})
})
}
);
}
}
module.exports = CopyDirWebpackPlugin;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/kesai/cesium-heatmap-es6.git
git@gitee.com:kesai/cesium-heatmap-es6.git
kesai
cesium-heatmap-es6
cesium-heatmap-es6
main

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385