2021-06-29 05:27:27 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-12-20 06:10:46 +01:00
|
|
|
import copy from '@guanghechen/rollup-plugin-copy';
|
|
|
|
import sourcemaps from 'rollup-plugin-sourcemaps';
|
|
|
|
import { terser } from 'rollup-plugin-terser';
|
|
|
|
import { distDirectory, name, sourceDirectory } from './tools/const.mjs';
|
2021-10-26 23:35:57 +02:00
|
|
|
|
2021-12-20 06:10:46 +01:00
|
|
|
const staticFiles = ['module.json', 'lang', 'templates'];
|
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
2021-10-27 23:04:35 +02:00
|
|
|
/**
|
|
|
|
* @type {import('rollup').RollupOptions}
|
|
|
|
*/
|
|
|
|
const config = {
|
2021-12-20 06:10:46 +01:00
|
|
|
input: { [`module/${name}`]: `${sourceDirectory}/module/${name}.js` },
|
2021-06-29 05:27:27 +02:00
|
|
|
output: {
|
2021-12-20 06:10:46 +01:00
|
|
|
dir: distDirectory,
|
2021-06-29 05:27:27 +02:00
|
|
|
format: 'es',
|
|
|
|
sourcemap: true,
|
2021-12-20 06:10:46 +01:00
|
|
|
assetFileNames: '[name].[ext]',
|
2021-06-29 05:27:27 +02:00
|
|
|
},
|
2021-12-20 06:10:46 +01:00
|
|
|
plugins: [
|
|
|
|
sourcemaps(),
|
|
|
|
copy({
|
|
|
|
targets: [{ src: staticFiles.map((file) => `${sourceDirectory}/${file}`), dest: distDirectory }],
|
|
|
|
}),
|
|
|
|
isProduction && terser({ ecma: 2020, keep_fnames: true }),
|
|
|
|
],
|
2021-06-29 05:27:27 +02:00
|
|
|
};
|
2021-10-27 23:04:35 +02:00
|
|
|
|
2021-12-20 06:10:46 +01:00
|
|
|
export default config;
|