tickwerk/rollup.config.js

60 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2022-05-16 02:08:27 +02:00
// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT
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}.js` },
2022-05-16 02:08:27 +02:00
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,
}),
2022-11-28 01:04:49 +01:00
copy({ targets: [{ src: staticFiles, dest: distDirectory }] }),
2022-05-16 02:08:27 +02:00
],
};
export default config;