-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrollup-base.config.js
47 lines (43 loc) · 1.23 KB
/
rollup-base.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
import process from 'process';
import path from 'path';
import eslint from '@rollup/plugin-eslint';
import nodeResolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import livereload from 'rollup-plugin-livereload';
import postcss from 'rollup-plugin-postcss';
const formats = ['esm'];
const rootDir = path.join(process.cwd(), '..');
const name = path.basename(process.cwd());
/** @type {import("rollup").RollupOptions} */
const generateRollupBaseConfig = () => ({
input: 'src/index.ts',
output: formats.map((format) => ({
file: `dist/index.${format}.js`,
format,
name,
sourcemap: true,
})),
plugins: [
nodeResolve({ rootDir }),
eslint(),
typescript(),
postcss({
extract: 'theme.css',
sourceMap: true,
plugins: [],
}),
terser(),
process.env.ROLLUP_WATCH &&
livereload({
watch: 'dist',
}),
],
external: (id, parent, isResolved) => {
if (!isResolved) return false;
const rel = path.relative(rootDir, id);
const filenames = rel.split(path.sep);
return filenames[0] === 'node_modules' || filenames[1] === 'dist';
},
});
export default generateRollupBaseConfig;