tickwerk/rollup.config.js

59 lines
1.3 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';
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}.js` },
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 }] }),
],
};
export default config;