You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
在官方文档 jsc.minify.format | swc 中有这么一句话:These properties are mostly not implemented yet, but it exists to support passing terser config to swc minify without modification.(这些属性大多尚未实现,但它的存在是为了支持将 terser 配置传递到 swc minify 而不进行修改)
使用 rollup 打包用户脚本(user script)
用户脚本 OR 油猴脚本
用户脚本(user script)是指在浏览器中运行的脚本,用于自定义网页的行为和外观。这些脚本可以修改网页内容、添加新的功能、自动执行任务、屏蔽广告、修改样式等等。在油猴(Tampermonkey)插件中,用户脚本也被称为油猴脚本,因为这个插件专门用于编写、运行、管理用户脚本
为什么要使用 rollup 打包
最近在更新我的 油猴脚本 —— 115 小助手 时有点越来越头大(维护不动了),其头大的原因有:
配置 rollup
安装 rollup(当前使用的是 3.x 版本)
编写 rollup 配置文件
rollup.config.js
配置
package.json
-c
读取配置文件--environment
设置环境变量--watch
监听文件变化配置 CSS 编译
安装
rollup-plugin-postcss
配置
rollup.config.js
配置 TypeScript 编译器
安装
typescript
添加
tsconfig.json
文件在配置编译器时遇到点小问题,这里记录一下
使用 esbuild
安装
rollup-plugin-esbuild
配置
rollup.config.js
问题记录:
/** 这是注释 **/
(可以配置minify: true
压缩代码但这个不是我想要的)Comments not being removed in latest esbuild
使用 swc
安装
rollup-plugin-swc3
配置
rollup.config.js
问题记录:
/** 这是注释 **/
jsc.minify.format
配置项无效在官方文档 jsc.minify.format | swc 中有这么一句话:These properties are mostly not implemented yet, but it exists to support passing terser config to swc minify without modification.(这些属性大多尚未实现,但它的存在是为了支持将
terser
配置传递到swc minify
而不进行修改)使用 terser 移除注释
安装
rollup-plugin-terser
配置
rollup.config.js
配置油猴脚本头部信息
安装
rollup-plugin-userscript
配置
rollup.config.js
也可以使用 rollup-plugin-userscript
其他说明
pnpm
作为包管理器,如果你使用的是npm
或yarn
,请自行替换命令The text was updated successfully, but these errors were encountered: