-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.js
67 lines (64 loc) · 1.76 KB
/
rollup.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as Manifest from '@illandril/foundryvtt-utils/manifest';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import fs from 'fs-extra';
import copy from 'rollup-plugin-copy';
import globals, { description, repositoryURL } from './globals.js';
const target = 'dist';
const isDevelopment = process.env.BUILD === 'development';
export default {
input: 'src/index.ts',
output: {
file: `${target}/module.js`,
format: 'es',
banner: Object.entries(globals)
.map(([key, value]) => `const ${key} = ${JSON.stringify(value)};\n`)
.join(''),
sourcemap: isDevelopment,
sourcemapPathTransform: (sourcePath) => sourcePath.replace(/^..[/\\]?/, ''),
},
watch: {
chokidar: {
usePolling: true,
},
},
plugins: [
nodeResolve({ extensions: ['.js', '.ts'] }),
babel({
babelHelpers: 'bundled',
extensions: ['.js', '.ts'],
}),
copy({
targets: [
{ src: 'src/styles.css', dest: target },
{ src: 'src/lang', dest: target },
{ src: 'LICENSE', dest: target },
],
}),
{
name: 'moduleJSON',
buildStart: async () => {
const manifestData = await fs.readJSON('src/manifestData.json');
return fs.outputJSON(
`${target}/module.json`,
Manifest.generate({
...manifestData,
authors: [Manifest.IllandrilAuthorInfo],
...globals.moduleMetadata,
description,
repositoryURL,
}),
{ spaces: 2 },
);
},
},
{
name: 'lock',
buildStart: async () => {
if (isDevelopment) {
await fs.outputFile(`${target}/${globals.moduleMetadata.id}.lock`, '');
}
},
},
],
};