This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
rollup.config.js
65 lines (59 loc) · 1.6 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
/**
* Copyright (c) IBM, Corp. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { readdirSync } from 'fs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import litcss from 'rollup-plugin-lit-css';
import sass from 'sass';
const transformSassToCss = (data, { filePath }) =>
sass
.renderSync({
data,
file: filePath,
includePaths: [new URL('node_modules/', import.meta.url).pathname],
})
.css.toString();
const componentPaths = readdirSync('components/', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
// Remove icons from the list of components
const iconsDirIndex = componentPaths.indexOf('icons');
componentPaths.splice(iconsDirIndex, 1);
export default [
...componentPaths.map((component) => ({
input: `components/${component}/index.js`,
plugins: [
litcss({
include: '**/*.scss',
transform: transformSassToCss,
uglify: true,
}),
],
output: {
dir: `components/${component}/`,
format: 'esm',
sourcemap: true,
},
external: ['tslib', 'lit', /^lit\/.*/, /^@carbon\/.*/],
})),
{
input: `components/ui-shell/index.js`,
plugins: [
litcss({
include: '**/*.scss',
transform: transformSassToCss,
uglify: true,
}),
nodeResolve(),
terser(),
],
output: {
file: 'experimental-bundled-ui-shell.js',
format: 'iife',
},
},
];