-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
102 lines (93 loc) · 2.53 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import path from 'path';
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import multiEntry from "rollup-plugin-multi-entry";
import includePaths from 'rollup-plugin-includepaths';
import stylus from 'rollup-plugin-stylus-compiler';
import postcss from 'rollup-plugin-postcss';
import svgr from '@svgr/rollup';
import autoprefixer from 'autoprefixer';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
/* For resolving from base paths */
const includePathOptions = {
include: {},
paths: ['src', 'src/assets', 'src/styles'],
external: [],
extensions: ['.js', '.svg', '.styl']
};
const outputDir = 'dist/';
export default [
/* Rollup config for bundling React UI components */
{
input: "src/components/index.js",
// input: "src/components/**/*.js",
output: [
{
file: path.join(outputDir, pkg.main.replace(/\.js$/, `.min.js`)),
format: 'esm',
sourcemap: true
}
],
plugins: [
includePaths(includePathOptions),
multiEntry(),
svgr(),
stylus({
include: ['src/components/**/*.styl', 'src/styles/**/*.styl'],
compiler: {
globals: {
$vars: path.resolve('src/styles/_vars.styl')
}
}
}),
postcss({
include: ['src/components/**/*.css', 'src/styles/**/*.css'],
modules: false,
plugins: [
autoprefixer,
],
extract: path.join(outputDir, 'base.css'),
sourceMap: true,
}),
babel({
exclude: 'node_modules/**', // only transpile our source code
runtimeHelpers: true
}),
terser({
sourcemap: true,
compress: {
drop_console: true,
},
}),
resolve(), // so Rollup can find imported library
commonjs(), // so Rollup can convert `imported library to an ES module
],
external: [
...Object.keys(pkg.peerDependencies || {})
], // libraries used which are not to be imported with the bundle
},
/* Rollup config for building add-on ui css as utility */
{
input: 'src/styles/ui.styl',
output: {
file: path.join(outputDir, 'ui.css'),
format: 'es'
},
plugins: [
stylus({
include: ['src/styles/**/*.styl']
}),
postcss({
include: ['src/styles/**/*.css'],
modules: false,
plugins: [
autoprefixer,
],
extract: true,
sourceMap: true,
}),
]
},
];