-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
45 lines (41 loc) · 1.39 KB
/
rollup.config.js
File metadata and controls
45 lines (41 loc) · 1.39 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
import babelPlugin from '@rollup/plugin-babel';
import json from '@rollup/plugin-json';
import nodeResolverPlugin from '@rollup/plugin-node-resolve';
import url from '@rollup/plugin-url';
import less from 'rollup-plugin-less';
import pkg from './package.json';
const externals = [].concat(Object.keys(pkg.dependencies)).concat(Object.keys(pkg.peerDependencies));
const generateConfig = format => ({
external: path => externals.some(external => path.startsWith(external)),
input: 'src',
output: {
file: `dist/bundle.${format}.js`,
format,
sourcemap: true
},
plugins: [
babelPlugin({
babelHelpers: 'runtime',
plugins: [
['@babel/plugin-transform-runtime', {corejs: {version: 3}, useESModules: format === 'esm'}]
],
presets: [
['@babel/preset-env', {loose: true, modules: false}],
'@babel/preset-react'
]
}),
json(),
url({
limit: 10 * 1024, // Inline files < 10k, copy files > 10k
include: /\.(png|jpg|gif|ico|eot|svg|ttf|woff|woff2)$/u,
destDir: 'dist/'
}),
less({
minify: true,
sourcemap: true,
output: 'dist/styles.css'
}),
nodeResolverPlugin({extensions: ['.js', '.jsx']})
]
});
export default ['esm', 'cjs'].map(generateConfig);