Newer
Older
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
Bekerle, Patrizio
committed
import copy from 'rollup-plugin-copy';
import terser from '@rollup/plugin-terser';
Bekerle, Patrizio
committed
import serve from 'rollup-plugin-serve';
import del from 'rollup-plugin-delete';
import {getPackagePath, getDistPath} from '../../rollup.utils.js';
Bekerle, Patrizio
committed
const build = typeof process.env.BUILD !== 'undefined' ? process.env.BUILD : 'local';
console.log('build: ' + build);
Bekerle, Patrizio
committed
export default (async () => {
return {
input:
build != 'test'
? [
'src/dbp-knowledge-base-web-page-element-view.js',
'src/dbp-knowledge-base-web-page-element-view-demo.js',
]
: glob.sync('test/**/*.js'),
output: {
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: 'shared/[name].[hash].[format].js',
format: 'esm',
onwarn: function (warning, warn) {
// keycloak bundled code uses eval
if (warning.code === 'EVAL' && warning.id.includes('sha256.js')) {
return;
}
warn(warning);
},
plugins: [
del({
}),
resolve(),
commonjs(),
json(),
url({
limit: 0,
emitFiles: true,
build !== 'local' && build !== 'test' ? terser() : false,
copy({
targets: [
{src: 'assets/index.html', dest: 'dist'},
{src: 'assets/favicon.ico', dest: 'dist'},
{
src: await getPackagePath('@dbp-toolkit/common', 'assets/icons/*.svg'),
dest: 'dist/' + (await getDistPath('@dbp-toolkit/common', 'icons')),
},
process.env.ROLLUP_WATCH === 'true'
? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002})
: false,
],