forked from webex/react-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
81 lines (77 loc) · 2.1 KB
/
rollup.config.js
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
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) => {
let componentName;
const cssHash = base64.encode(css).substring(0, 8);
const paths = filename.split('/');
let index = paths.indexOf('@ciscospark');
if (index === -1) {
index = paths.indexOf('@webex');
}
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-object-rest-spread',
'@babel/plugin-transform-exponentiation-operator',
'@babel/plugin-external-helpers'
],
presets: [
'@babel/preset-react'
],
externalHelpers: true
})
],
input: 'src/index.js',
output: [{
dir: 'es',
format: 'esm',
sourcemap: true
}],
external: ['react', 'react-dom', 'prop-types', 'classnames', '@momentum-ui/react']
};