/* eslint-env node */ // This rollup script is run by the command: // 'npm run build' import path from 'path'; import {lstatSync, readdirSync} from 'fs'; import rimraf from 'rimraf'; import babel from '@rollup/plugin-babel'; import copy from 'rollup-plugin-copy'; import {nodeResolve} from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import nodePolyfills from 'rollup-plugin-polyfill-node'; import url from '@rollup/plugin-url'; // for XML/SVG files import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'; import {terser} from 'rollup-plugin-terser'; // import progress from 'rollup-plugin-progress'; import filesize from 'rollup-plugin-filesize'; // utility function const getDirectories = (source) => { const isDirectory = (dir) => { return lstatSync(dir).isDirectory(); }; return readdirSync(source).map((nme) => path.join(source, nme)).filter((i) => isDirectory(i)); }; // capture the list of files to build for extensions and ext-locales const extensionDirs = getDirectories('src/editor/extensions'); const dest = ['dist/editor', 'dist/editor/system']; // remove existing distribution // eslint-disable-next-line no-console rimraf('./dist', () => console.info('recreating dist')); // config for svgedit core module const config = [{ input: ['src/editor/index.js'], output: [ { format: 'es', inlineDynamicImports: true, sourcemap: true, file: 'dist/editor/index.js' }, { format: 'es', inlineDynamicImports: true, sourcemap: true, file: 'dist/editor/xdomain-index.js', intro: 'const XDOMAIN = true;' }, { format: 'system', dir: 'dist/editor/system', inlineDynamicImports: true } ], plugins: [ // progress(), copy({ targets: [ { src: 'src/editor/index.html', dest: 'dist/editor' }, { src: 'src/editor/index.html', dest: 'dist/editor', rename: 'xdomain-index.html', transform: (contents) => contents.toString() .replace('