24 lines
905 B
JavaScript
24 lines
905 B
JavaScript
import resolve from '@rollup/plugin-node-resolve'; // 解析模块
|
|
import commonjs from '@rollup/plugin-commonjs'; // 转换 CommonJS 为 ESModules
|
|
import babel from '@rollup/plugin-babel'; // Babel 支持
|
|
// import { terser } from 'rollup-plugin-terser'; // 可选:压缩代码
|
|
|
|
export default {
|
|
input: './src/client.js', // 入口文件
|
|
output: {
|
|
file: './public/client.js', // 输出文件
|
|
format: 'iife', // 输出格式:立即执行函数 (适合浏览器)
|
|
sourcemap: true, // 生成 Source Map 方便调试
|
|
},
|
|
plugins: [
|
|
resolve(), // 解析 node_modules 中的依赖
|
|
commonjs(), // 转换 CommonJS 模块
|
|
babel({
|
|
presets: ['@babel/preset-env', '@babel/preset-react'],
|
|
babelHelpers: 'bundled', // 使用打包后的 Babel helpers
|
|
exclude: 'node_modules/**', // 排除 node_modules
|
|
}),
|
|
// terser(), // 可选:压缩输出代码
|
|
],
|
|
};
|