-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrollup.config.js
More file actions
69 lines (64 loc) · 1.42 KB
/
Copy pathrollup.config.js
File metadata and controls
69 lines (64 loc) · 1.42 KB
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
import { readFileSync } from 'node:fs'
import typescript from '@rollup/plugin-typescript'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import terser from '@rollup/plugin-terser'
const pkg = JSON.parse(
readFileSync(new URL('./package.json', import.meta.url), 'utf-8')
)
const banner = `/*!\n * PhpSPA Client Runtime v${pkg.version}\n * Docs: ${pkg.homepage} | Package: ${pkg.name}\n * License: ${pkg.license}\n */`
const terserOptions = {}
Object.defineProperty(terserOptions, 'maxWorkers', {
value: 1,
enumerable: true,
writable: true
})
export default {
input: 'lib/index.ts',
output: [
// --- UMD build for browsers and CDN ---
{
file: 'src/script/phpspa.js',
format: 'umd',
name: 'phpspa',
exports: 'named',
banner
},
// --- Minified UMD for production CDN ---
{
file: 'src/script/phpspa.min.js',
format: 'umd',
name: 'phpspa',
exports: 'named',
plugins: [
terser(terserOptions)
],
banner
},
// --- CommonJS for Node.js ---
{
file: 'src/script/phpspa.cjs',
format: 'cjs',
exports: 'named',
banner
},
// --- ES Module for modern bundlers ---
{
file: 'src/script/phpspa.mjs',
format: 'es',
banner
}
],
plugins: [
resolve({
browser: true
}),
commonjs(),
typescript({
tsconfig: './tsconfig.json',
declaration: true,
declarationDir: './src/script/types',
rootDir: './lib'
})
]
}