mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 15:26:17 +00:00
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
|
|
||
|
const { resolve } = require('./resolve');
|
||
|
const { rollup } = require('rollup');
|
||
|
const alias = require('@rollup/plugin-alias');
|
||
|
const commonjs = require('@rollup/plugin-commonjs');
|
||
|
const nodeResolve = require('@rollup/plugin-node-resolve');
|
||
|
const replace = require('@rollup/plugin-replace');
|
||
|
const babel = require('rollup-plugin-babel');
|
||
|
const svg = require('rollup-plugin-react-svg');
|
||
|
const { terser } = require('rollup-plugin-terser');
|
||
|
|
||
|
const plugins = [
|
||
|
replace({ 'process.env.NODE_ENV': '"production"' }),
|
||
|
alias({
|
||
|
entries: [
|
||
|
{ find: 'react', replacement: 'preact/compat' },
|
||
|
{ find: 'react-dom', replacement: 'preact/compat' },
|
||
|
{ find: 'svg', replacement: resolve('svg') },
|
||
|
{ find: 'utils', replacement: resolve('build/lib/util.js') },
|
||
|
],
|
||
|
}),
|
||
|
svg(),
|
||
|
babel({
|
||
|
exclude: 'node_modules/**',
|
||
|
}),
|
||
|
nodeResolve(),
|
||
|
commonjs({
|
||
|
include: 'node_modules/**',
|
||
|
}),
|
||
|
];
|
||
|
|
||
|
|
||
|
module.exports = exports = async function (input, prod) {
|
||
|
const inputOptions = {
|
||
|
input,
|
||
|
plugins,
|
||
|
};
|
||
|
|
||
|
const outputOptions = {
|
||
|
format: 'iife',
|
||
|
sourcemap: 'inline',
|
||
|
plugins: prod
|
||
|
? [ terser({ output: { comments: false } }) ]
|
||
|
: undefined,
|
||
|
|
||
|
};
|
||
|
|
||
|
const bundle = await rollup(inputOptions);
|
||
|
const output = await bundle.generate(outputOptions);
|
||
|
|
||
|
// console.log(output);
|
||
|
return output.output[0].code;
|
||
|
};
|