rollup-plugin-string
2024年01月12日
一、认识
rollup-plugin-string
用于处理 .html
文件
import tpl from "./tpl.html";
console.log(`Template for render: ${tpl}`);
二、配置
import { rollup } from "rollup";
import { string as String} from 'rollup-plugin-string';
rollup({
entry: "main.js",
plugins: [
String({
// Required to be specified
include: "**/*.html",
// Undefined by default
exclude: ["**/index.html"]
})
]
});
三、使用
import tpl from "./tpl.html"
const container = document.querySelector("root");
container.innerHTML = tpl;