generated from typhonjs-fvtt-demo/template-svelte-esm
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
80 lines (68 loc) · 2.88 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { babel } from '@rollup/plugin-babel';
import postcss from 'rollup-plugin-postcss'; // Process Sass / CSS w/ PostCSS
import resolve from '@rollup/plugin-node-resolve'; // This resolves NPM modules from node_modules.
import svelte from 'rollup-plugin-svelte';
import preprocess from 'svelte-preprocess';
import { terser } from 'rollup-plugin-terser'; // Terser is used for minification / mangling
import {
postcssConfig,
terserConfig,
typhonjsRuntime } from '@typhonjs-fvtt/runtime/rollup';
const s_COMPRESS = false; // Set to true to compress the module bundle.
const s_SOURCEMAPS = true; // Generate sourcemaps for the bundle (recommended).
// Set to true to enable linking against the TyphonJS Runtime Library module.
// You must add a Foundry module dependency on the `typhonjs` Foundry package or manually install it in Foundry from:
// https://github.com/typhonjs-fvtt-lib/typhonjs/releases/latest/download/module.json
const s_TYPHONJS_MODULE_LIB = false;
// Creates a standard configuration for PostCSS with autoprefixer & postcss-preset-env.
const postcssMain = postcssConfig({
extract: 'koboldtools_foundry.css',
compress: s_COMPRESS,
sourceMap: s_SOURCEMAPS
});
const s_RESOLVE_CONFIG = {
browser: true,
dedupe: ['svelte']
}
export default () =>
{
// Defines potential output plugins to use conditionally if the .env file indicates the bundles should be
// minified / mangled.
const outputPlugins = s_COMPRESS ? [terser(terserConfig())] : [];
// Defines whether source maps are generated / loaded.
const sourcemap = s_SOURCEMAPS;
return [
{ // The main module bundle
input: `src/init.js`,
output: {
file: `dist/koboldtools_foundry.js`,
format: 'es',
plugins: outputPlugins,
sourcemap
},
plugins: [
svelte({
preprocess: preprocess(),
onwarn: (warning, handler) =>
{
// Suppress `a11y-missing-attribute` for missing href in <a> links.
// Foundry doesn't follow accessibility rules.
if (warning.message.includes(`<a> element should have an href attribute`)) { return; }
// Let Rollup handle all other warnings normally.
handler(warning);
},
}),
postcss(postcssMain),
resolve(s_RESOLVE_CONFIG),
// When s_TYPHONJS_MODULE_LIB is true transpile against the Foundry module version of TRL.
s_TYPHONJS_MODULE_LIB && typhonjsRuntime(),
babel({
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', { bugfixes: true, shippedProposals: true, targets: { esmodules: true } }]
]
})
]
}
];
};