最近期末成绩也出了(大抵是寄了),觉得学校的教务系统实在太丑,决定写一个浏览器插件美化插件。
打开教务系统,一股00年代的复古拟物风格袭来,无数tr
td
![](/_next/image?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Ffiless%2Fimg3%40main%2F2023%2F01%2F19%2F1674135191542-5a8b7b7f-036d-42a5-9cb0-3edb05d9f880.png&w=3840&q=75)
前置知识
搭建脚手架
为了减轻插件体积,我们采用优秀的 react 替代品 preact 开发用户页面。
安装一系列依赖
yarn add preact yarn add -D @rollup/plugin-node-resolve @rollup/plugin-commonjs @rollup/plugin-typescript @rollup/plugin-babel yarn add -D @babel/core @rollup/plugin-alias @babel/plugin-transform-react-jsx
编写 rollup 配置。
import { nodeResolve } from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; import typescript from "@rollup/plugin-typescript"; import { babel } from "@rollup/plugin-babel"; const extensions = [".js", ".jsx", ".ts", ".tsx"]; export default [ { input: "src/components/content.js", output: [ { file: "dist/content.bundle.cjs.js", format: "cjs", sourcemap: true, }, { file: "dist/content.bundle.esm.js", format: "esm", sourcemap: true, }, ], plugins: [ nodeResolve({ extensions }), commonjs(), babel({ babelHelpers: "bundled", extensions, include: ["src/**/*"], }), ], }, ];
![](/_next/image?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Ffiless%2Fimg3%40main%2F2023%2F01%2F18%2F1674014555394-c7bdfd44-7991-462f-8f57-ed2cfa157369.png&w=3840&q=75)