aaefc9c3fc
- 引入 BaseComponent 基类统一管理事件、定时器和脚本加载 - 重构 timestamp 模块为继承自 BaseComponent 的类组件 - 新增 ScriptManager 工具类用于动态加载和卸载脚本 - 修改路由配置支持按需加载页面对应的 JS 模块 - 路由切换时自动销毁旧组件实例以防止内存泄漏 - 更新文件引用路径适配新的目录结构 - 修复 rollup 配置中的语法问题及端口配置 - 移除无用的日志输出和冗余代码提升性能
45 lines
993 B
JavaScript
45 lines
993 B
JavaScript
import {defineConfig} from 'rollup';
|
|
import resolve from '@rollup/plugin-node-resolve';
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
import json from '@rollup/plugin-json';
|
|
import livereload from 'rollup-plugin-livereload';
|
|
import serve from 'rollup-plugin-serve';
|
|
|
|
const basePlugins = [resolve(), commonjs(), json()];
|
|
|
|
const devPlugins = [
|
|
livereload({
|
|
watch: ['dist', 'sidepanel'],
|
|
verbose: false,
|
|
}),
|
|
serve({
|
|
open: true,
|
|
port: 3000,
|
|
contentBase: ['.', 'sidepanel'],
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
},
|
|
}),
|
|
];
|
|
|
|
export default defineConfig([
|
|
{
|
|
input: 'sidepanel/js/index.js',
|
|
output: {
|
|
file: 'dist/index.js',
|
|
format: 'iife',
|
|
name: 'MainPage',
|
|
},
|
|
plugins: [...basePlugins, ...devPlugins],
|
|
},
|
|
|
|
{
|
|
input: 'sidepanel/js/timestamp.js',
|
|
output: {
|
|
file: 'dist/timestamp.js',
|
|
format: 'iife',
|
|
name: 'TimestampPage',
|
|
},
|
|
plugins: [...basePlugins, ...devPlugins],
|
|
},
|
|
]); |