From e94a72d8c3c3dff5e62bd5cc80705f93eceadabd Mon Sep 17 00:00:00 2001 From: josef Date: Fri, 21 May 2021 08:23:54 -0500 Subject: [PATCH] update ssr build --- rollup.config.js | 49 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index f914fe5..8fbb4b0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -3,36 +3,25 @@ import resolve from '@rollup/plugin-node-resolve' import sveld from 'sveld' import pkg from './package.json' -const name = pkg.name - .replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3') - .replace(/^\w/, m => m.toUpperCase()) - .replace(/-\w/g, m => m[1].toUpperCase()) +export default ['es', 'umd'].map(format => { + const UMD = format === 'umd' -const svelteConfig = { - input: pkg.svelte, - output: [ - { file: pkg.module, format: 'es' }, - { file: pkg.main, format: 'umd', name }, - ], - external: Object.keys(pkg.dependencies), - plugins: [ - svelte({ - emitCss: false, - compilerOptions: { - generate: 'ssr', - }, - }), - resolve(), - sveld(), - ], -} + const svelteConfig = { + emitCss: false, + } -// const preprocessConfig = { -// input: 'support/preprocess.js', -// output: [ -// { file: './lib/preprocess.mjs', format: 'es' }, -// { file: './lib/preprocess.js', format: 'cjs' }, -// ], -// } + if (UMD) { + svelteConfig.compilerOptions = { generate: 'ssr' } + } -export default [svelteConfig] + return { + input: pkg.svelte, + output: { + file: UMD ? pkg.main : pkg.module, + format, + name: UMD ? pkg.name : undefined, + }, + external: Object.keys(pkg.dependencies), + plugins: [svelte(svelteConfig), resolve(), UMD && sveld()], + } +})