Skip to content
Snippets Groups Projects
rollup.config.js 2.21 KiB
Newer Older
import path from 'path';
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 json from 'rollup-plugin-json';
import serve from 'rollup-plugin-serve';
import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete';
import chai from 'chai';
Reiter, Christoph's avatar
Reiter, Christoph committed
const pkg = require('./package.json');
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build);

    input: (build != 'test') ? ['src/vpu-auth.js', 'src/vpu-auth-demo.js'] : glob.sync('test/**/*.js'),
        dir: 'dist',
        entryFileNames: '[name].js',
        chunkFileNames: 'shared/[name].[hash].[format].js',
        format: 'esm',
        sourcemap: true
    onwarn: function (warning, warn) {
        // keycloak bundled code uses eval
        if (warning.code === 'EVAL') {
            return;
        }
        // ignore chai warnings
        if (warning.code === 'CIRCULAR_DEPENDENCY') {
            return;
        }
        del({
            targets: 'dist/*'
        }),
        consts({
            environment: build,
        }),
        resolve({
          customResolveOptions: {
            // ignore node_modules from vendored packages
            moduleDirectory: path.join(process.cwd(), 'node_modules')
          }
        }),
            include: 'node_modules/**',
            namedExports: {
                'chai': Object.keys(chai),
            }
        (build !== 'local' && build !== 'test') ? terser() : false,
Reiter, Christoph's avatar
Reiter, Christoph committed
                {src: 'assets/index.html', dest:'dist'},
Reiter, Christoph's avatar
Reiter, Christoph committed
                {src: 'assets/silent-check-sso.html', dest: 'dist/local/' + pkg.name},
Reiter, Christoph's avatar
Reiter, Christoph committed
                {src: 'assets/favicon.ico', dest:'dist'},
Reiter, Christoph's avatar
Reiter, Christoph committed
                {src: 'node_modules/vpu-common/assets/icons/*.svg', dest: 'dist/local/vpu-common/icons'},
Reiter, Christoph's avatar
Reiter, Christoph committed
            ]
        }),
        (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false