-
Notifications
You must be signed in to change notification settings - Fork 25
/
rollup.config.js
36 lines (33 loc) · 1.38 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
const commonjs = require("@rollup/plugin-commonjs");
const {nodeResolve} = require('@rollup/plugin-node-resolve');
const esbuild = require('rollup-plugin-esbuild');
const dynamicImportVars = require('@rollup/plugin-dynamic-import-vars');
const fs = require("fs");
const glob = require("glob");
const plugins = [
nodeResolve(),
commonjs(),
esbuild.default({
include: /\.[jt]sx?$/, // TODO Might have to include d.ts here
sourceMap: true,
minify: process.env.NODE_ENV === 'production',
}),
dynamicImportVars.default({}),
];
module.exports = function() {
const migrations = JSON.stringify(fs.readdirSync("src/migrations").filter(name => name.slice(0, 1) !== "." ).map(name => name.slice(0, -3)));
const hooks = JSON.stringify(fs.readdirSync('src/module/hooks').filter(name => name.slice(0, 1) !== "." ).map(name => name.slice(0, -3)));
const templates = JSON.stringify(glob.sync('static/templates/**/*.html').filter(name => name.slice(0, 1) !== "." ).map(file => file.replace("static", "systems/twodsix")));
return {
input: 'src/twodsix.ts',
output: {
file: 'dist/twodsix.bundle.js',
format: 'es',
sourcemap: true,
inlineDynamicImports: true,
intro: `const migrationFileNames = ${migrations};\nconst handlebarsTemplateFiles = ${templates};\nconst hookScriptFiles = ${hooks};`
},
plugins: plugins,
strictDeprecation: true
};
}