2022-05-16 02:08:27 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-10-17 21:23:17 +02:00
|
|
|
import { copy } from '@guanghechen/rollup-plugin-copy';
|
2022-05-16 02:08:27 +02:00
|
|
|
import styles from 'rollup-plugin-styles';
|
|
|
|
import { swc } from 'rollup-plugin-swc3';
|
|
|
|
|
|
|
|
import { distDirectory, name, sourceDirectory } from './tools/const.js';
|
|
|
|
|
|
|
|
const staticFiles = [
|
|
|
|
'.reuse',
|
|
|
|
'lang',
|
|
|
|
'LICENSE.md',
|
|
|
|
'LICENSES',
|
|
|
|
'README.md',
|
|
|
|
'module.json.license',
|
|
|
|
'module.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: isProduction && {
|
|
|
|
sourceMap: true,
|
|
|
|
mangle: {
|
|
|
|
keepClassNames: true,
|
|
|
|
keepFnNames: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
keepClassNames: true,
|
|
|
|
},
|
|
|
|
sourceMaps: true,
|
|
|
|
}),
|
|
|
|
styles({
|
|
|
|
mode: ['extract', `styles/${name}.css`],
|
|
|
|
url: false,
|
|
|
|
sourceMap: true,
|
|
|
|
minimize: isProduction,
|
|
|
|
}),
|
|
|
|
copy({
|
|
|
|
targets: [{ src: staticFiles, dest: distDirectory }],
|
|
|
|
verbose: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
export default config;
|