-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.mjs
45 lines (41 loc) · 1.2 KB
/
rollup.config.mjs
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
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import scss from "rollup-plugin-scss";
import versionInjector from "rollup-plugin-version-injector";
import fs from "fs";
const buildTargetDir = process.env.buildTargetDir ?? 'build';
/**
* Copies the manifest.json file over and inserts the version number from the package.json
* @param userConfig
* @returns {{generateBundle(*, *): void}}
*/
function copyManifest(userConfig) {
return {
generateBundle(outputOptions, bundle) {
const packageFile = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const version = packageFile.version;
let content = fs.readFileSync('manifest.json', 'utf8');
content = content.replace('[VI]{version}[/VI]', version);
fs.writeFileSync(`${userConfig.outputPath}/manifest.json`, content);
}
}
}
export default {
input: 'kln90b/KLN90B.tsx',
output: {
sourcemap: true,
dir: `${buildTargetDir}/html_ui/Pages/VCockpit/Instruments/NavSystems/GPS/KLN90B`,
format: 'es'
},
plugins: [
scss({ fileName: 'KLN90B.css' }),
resolve(),
copyManifest({
outputPath: buildTargetDir,
}),
versionInjector({
injectInComments: false,
}),
typescript(),
]
}