Skip to content
Snippets Groups Projects
rollup.config.js 1.29 KiB
Newer Older
import glob from 'glob';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
Reiter, Christoph's avatar
Reiter, Christoph committed
import copy from 'rollup-plugin-copy';
import {terser} from "rollup-plugin-terser";
import json from '@rollup/plugin-json';
Reiter, Christoph's avatar
Reiter, Christoph committed
import serve from 'rollup-plugin-serve';
Reiter, Christoph's avatar
Reiter, Christoph committed
import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete';
Reiter, Christoph's avatar
Reiter, Christoph committed

const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build);

export default {
    input: (build != 'test') ? ['src/vpu-language-select.js', 'src/vpu-language-select-demo.js'] : glob.sync('test/**/*.js'),
Reiter, Christoph's avatar
Reiter, Christoph committed
    output: {
        dir: 'dist',
        entryFileNames: '[name].js',
        chunkFileNames: 'shared/[name].[hash].[format].js',
        format: 'esm',
        sourcemap: true
Reiter, Christoph's avatar
Reiter, Christoph committed
    },
    plugins: [
Reiter, Christoph's avatar
Reiter, Christoph committed
        consts({
            environment: build,
        }),
        resolve(),
        commonjs(),
Reiter, Christoph's avatar
Reiter, Christoph committed
        json(),
        (build !== 'local' && build !== 'test') ? terser() : false,
        copy({
            targets: [
Reiter, Christoph's avatar
Reiter, Christoph committed
                {src: 'assets/index.html', dest: 'dist'},
Reiter, Christoph's avatar
Reiter, Christoph committed
            ],
        }),
        (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false
    ]
};