123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import nodeResolve from '@rollup/plugin-node-resolve'
- import commonjs from "@rollup/plugin-commonjs"
- import babel from '@rollup/plugin-babel'
- import terser from '@rollup/plugin-terser';
- import json from '@rollup/plugin-json'
- import ts from "rollup-plugin-typescript2"
- const extensions = [".js", ".ts"]
- const reserved = ['ComPDFKitJS', 'DataArray', 'LineType', 'PageSize', 'Rect', 'RGBColor', 'FontDa', 'PDFDestination', 'WidgetItem', 'WidgetItemsArray', 'TextFindItemArray', 'EditCharPlace', 'EndEditCharPlace', 'RectArray', 'CursorPoints', 'EditTextStyle', 'U8StringData', 'PDFRange', 'TextRectArray']
- const plugins = [
- json(),
- ts(),
- nodeResolve({
- preferBuiltins: true,
- mainFields: ['browser']
- }),
- commonjs(),
- babel({
- extensions,
- exclude: 'node_modules/**', // 防止打包node_modules下的文件
- // 使用预设
- presets: [['@babel/preset-env', {
- "modules": false,
- // 目标浏览器
- "targets": {
- "edge": '17',
- "firefox": '60',
- "chrome": '67',
- "safari": '10.0',
- 'ie': '10',
- },
- }]]
- })
- ]
- plugins.push(
- terser({
- mangle: {
- reserved
- }
- }))
- export default [{
- input: "./src/worker/compdfkit_worker.js",
- output: [
- {
- format: "es",
- file: "../webview/lib/PDFWorker.js"
- }
- // {
- // format: "es",
- // name: 'ComPDFKitViewer',
- // file: "./dist/webviewer.js",
- // sourcemap: false
- // }
- ],
- plugins
- },
- {
- input: "./src/index.js",
- output: [
- {
- format: "es",
- file: "../webview/lib/webview.min.js"
- }
- ],
- plugins
- }];
|