Skip to content

Commit

Permalink
Modularize ts to package into a single js file
Browse files Browse the repository at this point in the history
  • Loading branch information
hbl917070 committed Oct 16, 2024
1 parent c932c45 commit fb81f4f
Show file tree
Hide file tree
Showing 62 changed files with 3,785 additions and 3,691 deletions.
47 changes: 4 additions & 43 deletions Www/ejs/MainWindow/MainWindow.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,19 @@
<!-- 空白 icon -->
<link rel="icon" href="data:image/x-icon;,">

<!-- <base href="/"> -->

<!--google字體-->
<!-- <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@100&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@100&display=swap" rel="stylesheet"> -->

<link rel="stylesheet" href="./css/MainWindow/MainWindow.css">
<link rel="stylesheet" href="./css/Menu.css">
<link rel="stylesheet" href="./css/Msgbox.css">
<link rel="stylesheet" href="./css/Toast.css">

<link rel="stylesheet" href="./css/BaseWindow.css">
<script src="./js/BaseWindow.js"></script>
<script src="./js/Lib.js"></script>
<script src="./js/SvgList.js"></script>

<script src="./vender/hammer.min.js"></script>
<script src="./vender/jquery-3.6.0.min.js"></script>
<script src="./vender/jquery.easing.js"></script>

<script src="./js/Tiefseeview.js"></script>
<script src="./js/TiefseeScroll.js"></script>
<link rel="stylesheet" href="./css/Tiefseeview.css">

<!-- 多國語言 -->
<script src="./js/SvgList.js"></script>
<script src="./lang/langData.js"></script>
<script src="./js/I18n.js"></script>

<script src="./js/WebAPI.js"></script>
<script src="./js/Config.js"></script>
<script src="./js/MainWindow/IndexedDBManager.js"></script>
<script src="./js/MainWindow/MainToolbar.js"></script>
<script src="./js/MainWindow/FileLoad.js"></script>
<script src="./js/MainWindow/MainFileList.js"></script>
<script src="./js/MainWindow/MainDirList.js"></script>
<script src="./js/MainWindow/MainExif.js"></script>
<script src="./js/MainWindow/AiDrawingPrompt.js"></script>
<script src="./js/MainWindow/FileShow.js"></script>
<script src="./js/MainWindow/Iframes.js"></script>
<script src="./js/MainWindow/FileSort.js"></script>
<script src="./js/MainWindow/DirSort.js"></script>
<script src="./js/MainWindow/ImgSearch.js"></script>
<script src="./js/MainWindow/MainMenu.js"></script>
<script src="./js/MainWindow/Menu.js"></script>
<script src="./js/MainWindow/LargeBtn.js"></script>
<script src="./js/MainWindow/BulkView.js"></script>
<script src="./js/Msgbox.js"></script>
<script src="./js/Toast.js"></script>
<script src="./js/MainWindow/Script.js"></script>
<script src="./js/MainWindow/Hotkey.js"></script>
<script src="./js/MainWindow/Dragbar.js"></script>
<script src="./js/MainWindow/MainWindow.js"></script>

<script src="./js/MainWindow.js"></script>
<link rel="stylesheet" href="./css/MainWindow.css">
</head>

<body showType="bulkView">
Expand Down
24 changes: 5 additions & 19 deletions Www/ejs/SettingWindow/SettingWindow.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,22 @@

<script src="./vender/jquery-3.6.0.min.js"></script>

<!-- MiniColors(選擇顏色套件 -->
<!-- MiniColors (選擇顏色器) -->
<script src="./vender/jquery-minicolors-master/jquery.minicolors.min.js"></script>
<link href="./vender/jquery-minicolors-master/jquery.minicolors.css" rel="stylesheet">

<!-- tippy(工具提示套件 -->
<!-- tippy (工具提示) -->
<script src="./vender/tippyjs/popper.min.js"></script>
<script src="./vender/tippyjs/tippy-bundle.umd.min.js"></script>

<!-- 拖曳排序物件 -->
<script src="./vender/Sortable.min.js"></script>

<link rel="stylesheet" href="./css/BaseWindow.css">
<script src="./js/BaseWindow.js"></script>
<script src="./js/Lib.js"></script>

<link rel="stylesheet" href="./css/SettingWindow/SettingWindow.css">
<!-- <link rel="stylesheet" href="./css/Menu.css"> -->
<link rel="stylesheet" href="./css/Msgbox.css">

<!-- 多國語言 -->
<script src="./lang/langData.js"></script>
<script src="./js/I18n.js"></script>

<script src="./js/Config.js"></script>
<script src="./js/SvgList.js"></script>
<!-- <script src="./js/MainWindow/Menu.js"></script> -->
<script src="./js/MainWindow/MainToolbar.js"></script>
<script src="./js/Msgbox.js"></script>
<script src="./js/SettingWindow/SettingWindow.js"></script>
<script src="./lang/langData.js"></script>

<script src="./js/SettingWindow.js"></script>
<link rel="stylesheet" href="./css/SettingWindow.css">
</head>

<body>
Expand Down
58 changes: 36 additions & 22 deletions Www/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,61 @@ gulp.task("svg", async () => {
// scss -> css
gulp.task("scss", async () => {
await sleep(1);
return gulp.src("./scss/**/*.scss") // 指定要處理的 Scss 檔案目錄
gulp.src("./scss/MainWindow/MainWindow.scss") // 指定要處理的 Scss 檔案目錄
.pipe(sass({
// outputStyle: "compressed", // 壓縮
}))
.pipe(gulp.dest("./css")) // 指定編譯後的 css 檔案目錄
.pipe(gulp.dest(output2 + "/css"))

gulp.src("./scss/SettingWindow/SettingWindow.scss")
.pipe(sass({
}))
.pipe(gulp.dest("./css"))
.pipe(gulp.dest(output2 + "/css"))
});

// ejs -> html
gulp.task("ejs-main", async () => {
gulp.task("ejs", async () => {
await sleep(1);
return gulp.src("./ejs/MainWindow/MainWindow.ejs")
gulp.src("./ejs/MainWindow/MainWindow.ejs")
.pipe(ejs({ readFile: readFile }, { async: true }))
.pipe(rename({ extname: ".html" })) // 修改輸出的副檔名
.pipe(gulp.dest("./"))
.pipe(gulp.dest(output2 + "/"))
});
gulp.task("ejs-setting", async () => {
await sleep(1);
return gulp.src("./ejs/SettingWindow/SettingWindow.ejs")

gulp.src("./ejs/SettingWindow/SettingWindow.ejs")
.pipe(ejs({ readFile: readFile }, { async: true }))
.pipe(rename({ extname: ".html" }))
.pipe(gulp.dest("./"))
.pipe(gulp.dest(output2 + "/"))

});

// ts -> js
gulp.task("ts", async () => {
await sleep(1);
return gulp.src("./ts/**/*.ts")
.pipe(gulpEsbuild({
// minify: true, // 壓縮
// outfile: "bundle.js",
// bundle: true,
// loader: { ".tsx": "tsx", },
}))
.pipe(gulp.dest("./js"))
.pipe(gulp.dest(output2 + "/js"))

var fileMappings = [
{ path: "./ts/MainWindow/MainWindow.ts", bundle: true },
{ path: "./ts/SettingWindow/SettingWindow.ts", bundle: true },
{ path: "./ts/TiefseeviewWorker.ts", bundle: true },
{ path: "./ts/TiefseeviewWorkerSub.ts", bundle: true },
{ path: "./ts/LibIframe.ts", bundle: false },
];

for (var i = 0; i < fileMappings.length; i++) {

gulp.src(fileMappings[i].path)
.pipe(gulpEsbuild({
// minify: true, // 壓縮
outfile: path.basename(fileMappings[i].path, ".ts") + ".js",
bundle: fileMappings[i].bundle,
// loader: { ".tsx": "tsx", },
}))
.pipe(gulp.dest("./js"))
.pipe(gulp.dest(output2 + "/js"))
}

});

// 把檔案複製到開發資料夾。 (有非 ts、scss、ejs 的資源需要複製到開發資料夾時使用
Expand Down Expand Up @@ -117,17 +132,16 @@ gulp.task("build-rust", (done) => {
});

// 打包 - 單次
gulp.task("build", gulp.series("scss", "ts", "svg", "ejs-main", "ejs-setting", "build-rust",
gulp.task("build", gulp.series("scss", "ts", "svg", "ejs", "build-rust",
"copy-files")); // copy-files 必須放在最後

// 打包 - 持續監控檔案變化
gulp.task("watch", gulp.series("scss", "ts", "svg", "ejs-main", "ejs-setting", () => {
gulp.task("watch", gulp.series("scss", "ts", "svg", "ejs", () => {
gulp.watch("./scss/**/*.scss", gulp.series("scss"));
gulp.watch("./ts/**/*.ts", gulp.series("ts"));
gulp.watch("./ejs/MainWindow/*.ejs", gulp.series("ejs-main"));
gulp.watch("./ejs/SettingWindow/*.ejs", gulp.series("ejs-setting"));
gulp.watch("./ejs/**/*.ejs", gulp.series("ejs"));

gulp.watch("./img/default/*.svg", gulp.series("ejs-main")); // svg 圖示
gulp.watch("./img/default/*.svg", gulp.series("ejs")); // svg 有可能會被 ejs 引用,所以也要重新執行 ejs
gulp.watch("./img/default/*.svg", gulp.series("svg"));
}));

Expand Down
151 changes: 0 additions & 151 deletions Www/scss/BaseStyle.scss

This file was deleted.

Loading

0 comments on commit fb81f4f

Please sign in to comment.