-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrollup.config.prod.ts
More file actions
122 lines (117 loc) · 3.44 KB
/
Copy pathrollup.config.prod.ts
File metadata and controls
122 lines (117 loc) · 3.44 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// rollup.config.prod.ts
import type { InputOptions, OutputOptions, RollupOptions } from 'rollup';
import {importMetaAssets} from "@web/rollup-plugin-import-meta-assets";
import { nodeResolve as nodeResolvePlugin } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescriptPlugin from '@rollup/plugin-typescript';
import postCssPlugin from 'rollup-plugin-postcss';
import babelPlugin from '@rollup/plugin-babel';
import analyzerPlugin from 'rollup-plugin-analyzer';
import terserPlugin from '@rollup/plugin-terser';
import imagePlugin from '@rollup/plugin-image';
import dtsPlugin from 'rollup-plugin-dts';
import path from 'path';
const libName = 'xibo-layout-renderer';
const outputPath = 'dist/';
const commonInputOptions: InputOptions = {
input: 'src/index.ts',
external: ['xibo-interactive-control', 'jquery'],
plugins: [
nodeResolvePlugin({
preferBuiltins: true,
mainFields: ['module', 'main'],
browser: true,
}),
commonjs({
include: ['node_modules/**'],
extensions: ['.js', '.ts'],
}),
babelPlugin({
include: ['src/**', 'node_modules/nanoevents/**'],
// extensions: ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts'],
extensions: ['.js', '.ts'],
passPerPreset: true,
babelHelpers: 'bundled',
presets: ['@babel/preset-env'],
}),
typescriptPlugin(),
postCssPlugin({
// all `*.css` files in src directory
extract: path.resolve('dist/styles.css'),
}),
imagePlugin(),
importMetaAssets(),
analyzerPlugin({
summaryOnly: true,
}),
],
};
const iifeCommonOutputOptions: OutputOptions = {
name: 'XiboLayoutRenderer',
};
const config: RollupOptions[] = [
{
...commonInputOptions,
output: [
{
file: `${outputPath}${libName}.esm.js`,
format: 'esm',
exports: 'named',
sourcemap: true,
globals: {
'jquery': '$',
},
}
],
},
{
...commonInputOptions,
output: [
{
...iifeCommonOutputOptions,
file: `${outputPath}${libName}.js`,
format: 'iife',
exports: 'named',
globals: {
'jquery': '$',
},
},
{
...iifeCommonOutputOptions,
file: `${outputPath}${libName}.min.js`,
format: 'iife',
sourcemap: true,
exports: 'named',
plugins: [
terserPlugin(),
],
globals: {
'jquery': '$',
},
}
],
},
{
...commonInputOptions,
plugins: [commonInputOptions.plugins],
output: [
{
file: `${outputPath}${libName}.cjs.js`,
format: 'cjs',
sourcemap: true,
exports: 'named',
}
],
},
{
...commonInputOptions,
plugins: [commonInputOptions.plugins, dtsPlugin()],
output: [
{
file: `${outputPath}${libName}.d.ts`,
format: 'esm',
}
],
}
];
export default config;