-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrollup.config.js
More file actions
60 lines (54 loc) · 1.52 KB
/
Copy pathrollup.config.js
File metadata and controls
60 lines (54 loc) · 1.52 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
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel';
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import multi from '@rollup/plugin-multi-entry';
import postcss from 'rollup-plugin-postcss';
import resolve from '@rollup/plugin-node-resolve';
// Rollup alias paths
const path = require('path');
const assets = path.resolve(__dirname, './src/assets');
const src = path.resolve(__dirname, './src');
const utilities = path.resolve(__dirname, './src/utilities');
// Post CSS plugins
const postcssPresetEnv = require('postcss-preset-env');
const autoprefixer = require('autoprefixer');
// Babel config path
const babelConfig = path.resolve(__dirname, '.babelrc');
// Helper function to create config
export default {
input: 'src/components/**/*.js',
output: [{
name: 'default-component-library',
sourcemap: true,
file: 'dist/index.js',
format: 'esm',
globals: { react: 'React' }
}],
plugins: [
alias({
entries: [
{ find: 'assets', replacement: assets },
{ find: 'src', replacement: src },
{ find: 'utilities', replacement: utilities }
]
}),
babel({
babelHelpers: 'bundled',
compact: true,
exclude: 'node_modules/**'
}),
commonjs(),
getBabelOutputPlugin({ configFile: babelConfig }),
multi(),
postcss({
extract: false,
modules: true,
plugins: [
autoprefixer(),
postcssPresetEnv({ stage: 0 })
],
use: [ 'sass' ]
}),
resolve()
]
};