-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.js
45 lines (38 loc) · 1.13 KB
/
index.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
// @flow
import * as path from 'path';
import rollupUrl from '@rollup/plugin-url';
import resolveToProductPath from '../../../path/resolve-to-product-path';
import getDestDir from './get-dest-dir';
interface ResolveFilesImport {
output?: string,
include?: Array<string>,
exclude?: Array<string>,
}
interface RollupFilesOptions {
resolveFilesImport: ResolveFilesImport,
input: string,
output: string,
context: string,
}
export default function rollupFiles(options: RollupFilesOptions): ?{[key: string]: any} {
const productContext = resolveToProductPath(path.join(options.context, '/'));
if (productContext)
{
const destDir = getDestDir({
destDir: options.resolveFilesImport.output,
output: options.output,
context: options.context,
});
const rollupUrlOptions = {
fileName: '[dirname][name][extname]',
publicPath: path.join(productContext, destDir, '/'),
destDir: path.join(options.context, destDir),
sourceDir: path.dirname(options.input),
include: options.resolveFilesImport.include,
exclude: options.resolveFilesImport.exclude,
limit: 0,
};
return rollupUrl(rollupUrlOptions);
}
return undefined;
}