加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rollup.config.mjs 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
Seth 提交于 2022-06-01 13:05 . feat: implement l10n using logseq-l10n
import html from "@rollup/plugin-html"
import json from "@rollup/plugin-json"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import { readFile } from "fs/promises"
import { defineRollupSwcOption, swc } from "rollup-plugin-swc3"
export default {
input: {
index: "src/index.js",
inline: "src/inline.js",
},
output: {
dir: "dist",
entryFileNames: "[name].[hash].js",
},
plugins: [
html({
fileName: "index.html",
template: async ({ files }) => {
const content = await readFile("src/index.html", { encoding: "utf8" })
const fileName = files.js.find(({ name }) => name === "index").fileName
return content
.replace(
"{preload}",
`<link rel="modulepreload" as="script" href="${fileName}" />`,
)
.replace("{js}", `<script type="module" src="${fileName}"></script>`)
},
}),
html({
fileName: "inline.html",
template: async ({ files }) => {
const content = await readFile("src/inline.html", { encoding: "utf8" })
const fileName = files.js.find(({ name }) => name === "inline").fileName
return content
.replace(
"{preload}",
`<link rel="modulepreload" as="script" href="${fileName}" />`,
)
.replace("{js}", `<script type="module" src="${fileName}"></script>`)
},
}),
nodeResolve(),
json(),
swc(
defineRollupSwcOption({
jsc: {
target: "es2021",
},
}),
),
],
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化