feat:add assets dealing

This commit is contained in:
pengfeizhou 2021-02-23 10:55:00 +08:00 committed by osborn
parent 2580088804
commit 752f0dbafd
3 changed files with 15 additions and 2 deletions

View File

@ -1,8 +1,8 @@
import { Shell } from "./shell"; import { Shell } from "./shell";
import { createMergedSourceMapFromFiles } from "source-map-merger" import { createMergedSourceMapFromFiles } from "source-map-merger"
import fs from "fs" import fs from "fs";
import { glob } from "./util"; import { glob } from "./util";
import path from "path";
export async function build() { export async function build() {
await Shell.exec("node", ["node_modules/.bin/tsc", "-p", "."]); await Shell.exec("node", ["node_modules/.bin/tsc", "-p", "."]);
await Shell.exec("node", ["node_modules/.bin/rollup", "-c"]); await Shell.exec("node", ["node_modules/.bin/rollup", "-c"]);
@ -10,6 +10,19 @@ export async function build() {
for (let bundleFile of bundleFiles) { for (let bundleFile of bundleFiles) {
await doMerge(bundleFile); await doMerge(bundleFile);
} }
if (fs.existsSync("assets")) {
const assets = await fs.promises.readdir("assets")
for (let asset of assets) {
const assetFile = path.resolve("assets", asset);
const stat = await fs.promises.stat(assetFile);
await Shell.exec("cp", ["-rf", assetFile, "bundle"]);
if (stat.isDirectory()) {
console.log(`Asset -> ${asset.yellow}`);
} else {
console.log(`Asset -> ${asset.green}`);
}
}
}
} }
export async function clean() { export async function clean() {

Binary file not shown.

Binary file not shown.