UNPKG

png-optimizer

Version:

58 lines (55 loc) 1.25 kB
/* * rollup.mjs * Created by 还有醋v on 2022/3/4. * Copyright © 2021 haiyoucuv. All rights reserved. */ import json from "@rollup/plugin-json"; import resolve from "@rollup/plugin-node-resolve"; import typescript from "@rollup/plugin-typescript"; import * as fs from "fs"; import path from "path"; import commonjs from "rollup-plugin-commonjs"; import progress from "rollup-plugin-progress"; import { terser } from "rollup-plugin-terser"; export default { input: "src/index.ts", cache: true, external: [ "fs", "path" ], output: [ { file: "dist/index.js", format: "cjs", }, { file: 'dist/index.module.js', format: 'esm', } ], plugins: [ progress(), function wasm2str() { return { name: "wasm2str", resolveId(source, importer, options) { const fileType = source.split('.').slice(-1)[0]; if (fileType === "wasm") return path.join(importer, "../", source); }, load(id) { const fileType = id.split('.').slice(-1)[0]; if (fileType === "wasm") { const str = fs.readFileSync(id).toString("base64"); return `export default \`${str}\``; } } } }(), typescript({ tsconfig: "./tsconfig.json" }), json(), resolve(), commonjs(), terser(), ] };