-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.mjs
22 lines (18 loc) · 786 Bytes
/
build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import {rmSync, mkdirSync, copyFile, writeFile} from 'fs';
import {transformFile} from '@babel/core';
import {compileFromFile} from 'json-schema-to-typescript';
rmSync('lib', {force: true, recursive: true});
mkdirSync('lib');
transformFile('src/index.js', (_, {code}) =>
writeFile('lib/index.js', code, () => {})
);
copyFile('src/options.json', 'lib/options.json', () => {});
compileFromFile('src/options.json', {format: false}).then((ts) =>
writeFile(
'lib/index.d.ts',
'import { Compiler } from "webpack";\n' +
ts.slice(ts.indexOf('interface Options')) +
'declare class WebpackExtensionManifestPlugin{constructor(options:Options);apply(compiler:Compiler):void;}\nexport = WebpackExtensionManifestPlugin;',
() => {}
)
);