-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs4
91 lines (85 loc) · 2.4 KB
/
rollup.config.mjs4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// rollup.config.js
import typescript from 'rollup-plugin-typescript2';
import vue from 'rollup-plugin-vue';
import scss from 'rollup-plugin-scss';
import css from 'rollup-plugin-css-only';
import { promises as fs } from 'fs';
import { builtinModules, createRequire } from 'module';
import { resolve } from 'path';
import { fileURLToPath } from 'url';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import esbuild from 'rollup-plugin-esbuild';
import json from '@rollup/plugin-json';
import replace from '@rollup/plugin-replace';
import alias from '@rollup/plugin-alias';
import dts from 'rollup-plugin-dts';
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
const DEV = !!process.env.DEV;
const PROD = !DEV;
const ROOT = fileURLToPath(import.meta.url);
const r = p => resolve(ROOT, '..', p);
const external = [
...Object.keys(pkg.dependencies),
...builtinModules.flatMap(m => (m.includes('punycode') ? [] : [m, `node:${m}`])),
r('types/shared.d.ts'),
];
const basePlugins = [
alias({
entries: {
'readable-stream': 'stream',
},
}),
replace({
'navigator.userAgentData': 'undefined',
'navigator.userAgent': 'undefined',
preventAssignment: true,
}),
commonjs(),
nodeResolve({ preferBuiltins: false }),
esbuild({ target: 'node14' }),
json(),
];
export default [
{
input: r('src/index.ts'),
output: {
format: 'esm',
entryFileNames: `[name].js`,
chunkFileNames: 'serve-[hash].js',
dir: r('dist'),
sourcemap: DEV,
},
external,
plugins: [
...basePlugins,
typescript({
tsconfig: './tsconfig.json', // Убедитесь, что путь к вашему tsconfig правильный
compilerOptions: {
module: 'esnext', // Задайте модуль 'esnext'
outDir: r('dist'), // Убедитесь, что outDir совпадает с dir в настройках Rollup
},
}),
vue({
script: {
refSugar: true,
},
}),
scss(),
css({ output: 'bundle.css' }),
],
onwarn(warning, warn) {
if (warning.code !== 'EVAL') warn(warning);
},
},
{
input: r('src/index.ts'),
output: {
format: 'esm',
file: r('dist/index.d.ts'),
},
external,
plugins: [...basePlugins, dts({ respectExternal: true })],
},
];