forked from emotion-js/emotion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
72 lines (67 loc) · 1.62 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
import resolve from 'rollup-plugin-node-resolve'
import uglify from 'rollup-plugin-uglify'
import replace from 'rollup-plugin-replace'
import babel from 'rollup-plugin-babel'
import alias from 'rollup-plugin-alias'
import path from 'path'
const pkg = require(path.resolve(process.cwd(), './package.json'))
const config = {
entry: './src/index.js',
external: ['react', 'emotion', 'emotion-utils'],
exports: 'named',
sourceMap: true,
plugins: [
resolve(),
babel({
presets: [
[
'env',
{
loose: true,
modules: false,
exclude: ['transform-es2015-typeof-symbol']
}
],
'stage-0',
'react',
'flow'
],
plugins: ['codegen'],
babelrc: false
})
],
targets: [
{ dest: pkg.main, format: 'cjs' },
{ dest: pkg.module, format: 'es' }
]
}
if (process.env.UMD) {
config.external = ['react']
config.globals = { react: 'React' }
config.plugins.push(
alias({
emotion: path.resolve(__dirname, './packages/emotion/src/index.js'),
'emotion-utils': path.resolve(
__dirname,
'./packages/emotion-utils/src/index.js'
)
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
uglify()
)
config.targets = [
{
dest: './dist/DO-NOT-USE.min.js',
format: 'umd',
moduleName: pkg.name
}
]
}
if (pkg.name === 'preact-emotion') {
config.entry = '../react-emotion/src/index.js'
config.external = ['preact', 'emotion-utils', 'emotion']
config.plugins.unshift(alias({ react: 'preact' }))
}
export default config