Newer
Older
import glob from 'glob';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import terser from '@rollup/plugin-terser';
import serve from 'rollup-plugin-serve';
import del from 'rollup-plugin-delete';
import json from '@rollup/plugin-json';
import emitEJS from 'rollup-plugin-emit-ejs';
import {getPackagePath, getDistPath} from '../../rollup.utils.js';
import config from '../../demo.common.config.js';
const build = typeof process.env.BUILD !== 'undefined' ? process.env.BUILD : 'local';
console.log('build: ' + build);
const pkg = require('./package.json');
const basePath = '/dist/';
const appName = 'dbp-auth';
export default (async () => {
let privatePath = await getDistPath(pkg.name);
? ['src/' + appName + '.js', 'src/' + appName + '-demo.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({
emitEJS({
src: 'assets',
include: ['**/*.ejs', '**/.*.ejs'],
data: {
getUrl: (p) => {
return url.resolve(basePath, p);
},
getPrivateUrl: (p) => {
return url.resolve(`${basePath}${privatePath}/`, p);
},
name: appName,
entryPointURL: config.entryPointURL,
keyCloakBaseURL: config.keyCloakBaseURL,
keyCloakRealm: config.keyCloakRealm,
keyCloakClientId: config.keyCloakClientId,
},
}),
resolve(),
commonjs(),
json(),
build !== 'local' && build !== 'test' ? terser() : false,
copy({
targets: [
{src: 'assets/silent-check-sso.html', dest: 'dist'},
{
src: await getPackagePath('@dbp-toolkit/common', 'assets/icons/*.svg'),
dest: 'dist/' + (await getDistPath('@dbp-toolkit/common', 'icons')),
},
? serve({
contentBase: '.',
historyApiFallback: basePath + 'index.html',
host: '127.0.0.1',
port: 8002,
})