2021-06-26 22:02:00 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-11-30 17:30:25 +01:00
|
|
|
import copy from "@guanghechen/rollup-plugin-copy";
|
2022-01-21 02:26:48 +01:00
|
|
|
import typescript from "@rollup/plugin-typescript";
|
2021-11-30 17:30:25 +01:00
|
|
|
import styles from "rollup-plugin-styles";
|
|
|
|
import { terser } from "rollup-plugin-terser";
|
|
|
|
import { distDirectory, name, sourceDirectory } from "./tools/const.js";
|
|
|
|
import { convertJSONToPack } from "./tools/json-pack-tools.js";
|
|
|
|
|
2022-01-31 15:13:32 +01:00
|
|
|
const staticFiles = [
|
|
|
|
".reuse",
|
|
|
|
"assets",
|
|
|
|
"ATTRIBUTION.md",
|
|
|
|
"fonts",
|
|
|
|
"lang",
|
2022-01-31 16:56:50 +01:00
|
|
|
"LICENSE.md",
|
2022-01-31 15:13:32 +01:00
|
|
|
"LICENSES",
|
|
|
|
"README.md",
|
|
|
|
"system.json.license",
|
|
|
|
"system.json",
|
|
|
|
"template.json.license",
|
|
|
|
"template.json",
|
|
|
|
"templates",
|
|
|
|
];
|
2021-11-30 17:30:25 +01:00
|
|
|
const isProduction = process.env.NODE_ENV === "production";
|
2021-03-17 12:15:25 +01:00
|
|
|
|
2021-10-27 19:11:43 +02:00
|
|
|
/**
|
|
|
|
* @type {import('rollup').RollupOptions}
|
|
|
|
*/
|
|
|
|
const config = {
|
2022-01-31 15:13:32 +01:00
|
|
|
input: { [`${name}`]: `${sourceDirectory}/${name}.ts` },
|
2021-03-17 12:15:25 +01:00
|
|
|
output: {
|
2021-11-30 17:30:25 +01:00
|
|
|
dir: distDirectory,
|
2021-03-17 12:15:25 +01:00
|
|
|
format: "es",
|
|
|
|
sourcemap: true,
|
2021-11-30 17:30:25 +01:00
|
|
|
assetFileNames: "[name].[ext]",
|
2021-03-17 12:15:25 +01:00
|
|
|
},
|
2021-10-27 19:11:43 +02:00
|
|
|
plugins: [
|
2022-02-12 04:18:49 +01:00
|
|
|
typescript(),
|
2021-11-30 17:30:25 +01:00
|
|
|
styles({
|
|
|
|
mode: ["extract", `css/${name}.css`],
|
|
|
|
url: false,
|
|
|
|
sourceMap: true,
|
|
|
|
minimize: isProduction,
|
|
|
|
}),
|
|
|
|
copy({
|
|
|
|
targets: [
|
2022-01-31 15:13:32 +01:00
|
|
|
{ src: staticFiles, dest: distDirectory },
|
2021-11-30 17:30:25 +01:00
|
|
|
{
|
2022-01-31 15:13:32 +01:00
|
|
|
src: [`packs/*.json`],
|
2021-11-30 17:30:25 +01:00
|
|
|
dest: `${distDirectory}/packs`,
|
|
|
|
rename: (name) => `${name}.db`,
|
|
|
|
transform: convertJSONToPack,
|
|
|
|
},
|
2022-01-31 15:13:32 +01:00
|
|
|
{
|
|
|
|
src: [`packs/*.json.license`],
|
|
|
|
dest: `${distDirectory}/packs`,
|
|
|
|
rename: (name, extension) => `${name.replace(".json", ".db")}.${extension}`,
|
|
|
|
},
|
2021-11-30 17:30:25 +01:00
|
|
|
],
|
2022-02-16 01:32:50 +01:00
|
|
|
verbose: true,
|
2021-11-30 17:30:25 +01:00
|
|
|
}),
|
|
|
|
isProduction && terser({ ecma: 2020, keep_fnames: true }),
|
2021-10-27 19:11:43 +02:00
|
|
|
],
|
2021-03-17 12:15:25 +01:00
|
|
|
};
|
2021-10-27 19:11:43 +02:00
|
|
|
|
2021-11-30 17:30:25 +01:00
|
|
|
export default config;
|