73 lines
1.9 KiB
JavaScript
73 lines
1.9 KiB
JavaScript
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import copy from "@guanghechen/rollup-plugin-copy";
|
|
import styles from "rollup-plugin-styles";
|
|
import { swc } from "rollup-plugin-swc3";
|
|
|
|
import { distDirectory, name, sourceDirectory } from "./tools/const.js";
|
|
import { convertJSONToPack } from "./tools/json-pack-tools.js";
|
|
|
|
const staticFiles = [
|
|
".reuse",
|
|
"assets",
|
|
"ATTRIBUTION.md",
|
|
"fonts",
|
|
"lang",
|
|
"LICENSE.md",
|
|
"LICENSES",
|
|
"README.md",
|
|
"system.json.license",
|
|
"system.json",
|
|
"template.json.license",
|
|
"template.json",
|
|
"templates",
|
|
];
|
|
const isProduction = process.env.NODE_ENV === "production";
|
|
|
|
/**
|
|
* @type {import('rollup').RollupOptions}
|
|
*/
|
|
const config = {
|
|
input: { [name]: `${sourceDirectory}/${name}.ts` },
|
|
output: {
|
|
dir: distDirectory,
|
|
format: "es",
|
|
sourcemap: true,
|
|
assetFileNames: "[name].[ext]",
|
|
},
|
|
plugins: [
|
|
swc({
|
|
minify: isProduction,
|
|
jsc: { minify: { sourceMap: true, keepFnames: true } },
|
|
sourceMaps: true,
|
|
}),
|
|
styles({
|
|
mode: ["extract", `css/${name}.css`],
|
|
url: false,
|
|
sourceMap: true,
|
|
minimize: isProduction,
|
|
}),
|
|
copy({
|
|
targets: [
|
|
{ src: staticFiles, dest: distDirectory },
|
|
{
|
|
src: [`packs/*.json`],
|
|
dest: `${distDirectory}/packs`,
|
|
rename: (name) => `${name}.db`,
|
|
transform: convertJSONToPack,
|
|
},
|
|
{
|
|
src: [`packs/*.json.license`],
|
|
dest: `${distDirectory}/packs`,
|
|
rename: (name, extension) => `${name.replace(".json", ".db")}.${extension}`,
|
|
},
|
|
],
|
|
verbose: true,
|
|
}),
|
|
],
|
|
};
|
|
|
|
export default config;
|