-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.js
More file actions
59 lines (55 loc) · 1.88 KB
/
Copy pathrollup.config.js
File metadata and controls
59 lines (55 loc) · 1.88 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
import json from '@rollup/plugin-json';
import path from 'path';
import esbuild from 'rollup-plugin-esbuild';
import sourcemaps from 'rollup-plugin-sourcemaps';
import { typescriptPaths } from 'rollup-plugin-typescript-paths';
import { colorfulLogs, colors } from './scripts/rollup-colorfulLogs';
import { execSync } from 'child_process';
// Function to automatically mark all non-local imports as external
// avoids warning message about external dependencies
const isExternal = (id, ...overArgs) => {
const _isExternal = !id.startsWith('.') && !path.isAbsolute(id) && !id.startsWith('@/');
return _isExternal;
};
const config = {
input: 'src/index.ts',
output: {
file: 'dist/index.js',
format: 'es',
sourcemap: true,
},
external: isExternal,
plugins: [
colorfulLogs('Smyth Builder'),
ctixPlugin(), // Add ctix plugin as first plugin
json(),
typescriptPaths({
tsconfig: './tsconfig.json',
preserveExtensions: true,
nonRelative: false,
}),
sourcemaps(),
esbuild({
sourceMap: true,
minify: false,
treeShaking: false,
sourcesContent: true,
}),
],
};
export default config;
// Custom ctix plugin to generate barrel files
function ctixPlugin(options = {}) {
return {
name: 'ctix-barrel-generator',
buildStart() {
try {
process.stdout.write(`\n${colors.cyan}⚙️ ${colors.yellow} Generating barrel files...${colors.reset}\n`);
execSync('npm exec ctix build', { stdio: 'inherit' });
console.log(`${colors.green}✅ ${colors.bright}Barrel files generated successfully!${colors.reset}\n`);
} catch (error) {
this.error(`Failed to generate ctix barrel files: ${error.message}`);
}
},
};
}