代码拉取完成,页面将自动刷新
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",
},
}),
),
],
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。