forked from webex/react-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.calling-config.js
More file actions
174 lines (165 loc) · 5.1 KB
/
rollup.calling-config.js
File metadata and controls
174 lines (165 loc) · 5.1 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// import resolve from '@rollup/plugin-node-resolve';
// import commonjs from '@rollup/plugin-commonjs';
// // import typescript from 'rollup-plugin-typescript2';
// import external from 'rollup-plugin-peer-deps-external';
// // import dts from 'rollup-plugin-dts';
// import visualizer from 'rollup-plugin-visualizer';
// import license from 'rollup-plugin-license';
// import del from 'rollup-plugin-delete';
// import scss from 'rollup-plugin-scss';
// import { terser } from 'rollup-plugin-terser';
// import copy from 'rollup-plugin-copy';
// // import typescript from 'typescript'
// // import ts from 'rollup-plugin-typescript2';
// const packageJson = require('./packages/node_modules/@webex/widget-call-history/package.json');
// const moduleName = packageJson.name.replace('@', '').replace('/', '-');
// const outputFolderRootPath = './packages/node_modules/@webex/widget-call-history/';
// // const packageJson = require('./packages/node_modules/@webex/widgets');
// export default [
// {
// input: packageJson.src,
// output: [
// {
// file: packageJson.main,
// format: 'cjs',
// sourcemap: true,
// name: moduleName,
// },
// {
// file: `${packageJson.main.slice(0, -3)}.min.js`,
// format: 'cjs',
// sourcemap: true,
// plugins: [terser()],
// },
// {
// file: packageJson.module,
// format: 'esm',
// sourcemap: true,
// },
// {
// file: `${packageJson.module.slice(0, -3)}.min.js`,
// format: 'esm',
// sourcemap: true,
// plugins: [terser()],
// },
// ],
// plugins: [
// del({ targets: outputFolderRootPath + 'dist/*' }),
// external(),
// resolve({
// browser: true,
// }),
// commonjs(),
// // ts({
// // typescript
// // }),
// // typescript({
// // tsconfig: './tsconfig.json',
// // outputToFilesystem: true,
// // }),
// scss({
// output: outputFolderRootPath + `dist/css/${moduleName}.css`,
// failOnError: true,
// }),
// copy({
// targets: [
// { src: 'src/localization/locales', dest: outputFolderRootPath + 'dist/cjs/' },
// {
// src: 'src/localization/locales',
// dest: outputFolderRootPath + 'dist/esm/',
// },
// ],
// }),
// license({
// banner: `
// Webex Calling
// Copyright (c) <%= new Date().toISOString() %> Cisco Systems, Inc and its affiliates.
// This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
// `,
// }),
// visualizer({
// filename: 'coverage/bundle-analysis-esm.html',
// title: 'Webex Calling Components ESM Bundle Analysis',
// }),
// ],
// },
// // /* Rollup Types */
// // {
// // input: outputFolderRootPath + 'esm/src/index.d.ts',
// // output: [{ file: outputFolderRootPath + 'dist/esm/src/index.ts', format: 'esm' }],
// // external: [/\.css$/, /\.scss$/],
// // plugins: [dts()],
// // },
// ];
import babel from 'rollup-plugin-babel';
import url from '@rollup/plugin-url';
import clear from 'rollup-plugin-clear';
import postcss from 'rollup-plugin-postcss';
import localResolve from 'rollup-plugin-local-resolve';
import {base64} from '@webex/common';
export default {
plugins: [
// Clears the destination directory before building
clear({
// required, point out which directories should be clear.
targets: ['es']
}),
// Finds the index.js file when importing via folder
localResolve(),
// Convert css to css modules
postcss({
modules: {
generateScopedName: (name, filename, css) => {
const cssHash = base64.encode(css).substring(0, 8);
const paths = filename.split('/');
const index = paths.indexOf('widget-call-history');
let componentName;
if (index !== -1) {
componentName = paths[index + 1];
}
else {
componentName = filename;
}
return `${componentName}__${name}__${cssHash}`;
}
},
// Don't use sass loader due to momentum-ui issues
use: [],
config: false
}),
// Inline images
url({
limit: 100 * 1024 // inline files < 100k, copy files > 100k
}),
// Audio files for ringtones
url({
limit: 0,
include: ['**/*.mp3']
}),
babel({
babelrc: false,
exclude: 'node_modules/**',
plugins: [
[
// Support for @autobind decorators
'@babel/plugin-proposal-decorators',
{
legacy: true
}
],
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining'
],
presets: [
'@babel/preset-react'
]
})
],
input: 'src/index.ts',
output: [{
dir: 'es',
format: 'esm',
sourcemap: true
}],
external: ['react', 'react-dom', 'prop-types', 'classnames', '@momentum-ui/react']
};