Skip to content
Snippets Groups Projects
Select Git revision
  • b081907b60a2894e6ef2e28700742b9c67134e1f
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

rollup.config.js

Blame
  • rollup.config.js 1.77 KiB
    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 json from '@rollup/plugin-json';
    import serve from 'rollup-plugin-serve';
    import consts from 'rollup-plugin-consts';
    import del from 'rollup-plugin-delete';
    
    const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
    console.log("build: " + build);
    
    let nextcloudBaseURL = 'https://cloud.tugraz.at';
    let nextcloudFileURL = nextcloudBaseURL + '/apps/files/?dir=';
    
    export default {
        input: (build !== 'test') ? ['src/demo.js', 'src/vpu-file-source.js'] : glob.sync('test/**/*.js'),
        output: {
            dir: 'dist',
            entryFileNames: '[name].js',
            chunkFileNames: 'shared/[name].[hash].[format].js',
            format: 'esm',
            sourcemap: true
        },
        plugins: [
            del({
                targets: 'dist/*'
            }),
            consts({
                environment: build,
                nextcloudBaseURL: nextcloudBaseURL,
                nextcloudFileURL: nextcloudFileURL,
            }),
            resolve(),
            commonjs(),
            json(),
            (build !== 'local' && build !== 'test') ? terser() : false,
            copy({
                targets: [
                    {src: 'assets/index.html', dest: 'dist'},
                    {src: 'assets/favicon.ico', dest: 'dist'},
                    {src: '../../node_modules/material-design-icons-svg/paths/*.json', dest: 'dist/local/vpu-common/icons'},
                    {src: '../../node_modules/tabulator-tables/dist/css', dest: 'dist/local/vpu-file-source/tabulator-tables'},
                ],
            }),
            (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false
        ]
    };