From 08e575fee08b1b802d458b8b56f544b58f8e0453 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Mon, 5 Feb 2018 13:43:10 -0800 Subject: [PATCH] shrink repetitive rollup.config file --- rollup.config.js | 108 ++++++++++------------------------------------- 1 file changed, 22 insertions(+), 86 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 9314270..6fe21fa 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,91 +11,27 @@ const paths = { 'sapper/core.js': './core.js' }; +const plugins = [ + typescript({ + typescript: require('typescript') + }) +]; + export default [ - // cli.js - { - input: 'src/cli/index.ts', - output: { - file: 'cli.js', - format: 'cjs', - banner: '#!/usr/bin/env node', - paths, - sourcemap: true - }, - external, - plugins: [ - typescript({ - typescript: require('typescript') - }) - ] + { name: 'cli', banner: true }, + { name: 'core', banner: true }, + { name: 'middleware' }, + { name: 'runtime', format: 'es' }, + { name: 'webpack', file: 'webpack/config' } +].map(obj => ({ + input: `src/${obj.name}/index.ts`, + output: { + file: `${obj.file || obj.name}.js`, + format: obj.format || 'cjs', + banner: obj.banner && '#!/usr/bin/env node', + paths, + sourcemap: true }, - - // core.js - { - input: 'src/core/index.ts', - output: { - file: 'core.js', - format: 'cjs', - banner: '#!/usr/bin/env node', - paths, - sourcemap: true - }, - external, - plugins: [ - typescript({ - typescript: require('typescript') - }) - ] - }, - - // middleware.js - { - input: 'src/middleware/index.ts', - output: { - file: 'middleware.js', - format: 'cjs', - paths, - sourcemap: true - }, - external, - plugins: [ - typescript({ - typescript: require('typescript') - }) - ] - }, - - // runtime.js - { - input: 'src/runtime/index.ts', - output: { - file: 'runtime.js', - format: 'es', - paths, - sourcemap: true - }, - external, - plugins: [ - typescript({ - typescript: require('typescript') - }) - ] - }, - - // webpack/config.js - { - input: 'src/webpack/index.ts', - output: { - file: 'webpack/config.js', - format: 'cjs', - paths, - sourcemap: true - }, - external, - plugins: [ - typescript({ - typescript: require('typescript') - }) - ] - } -]; \ No newline at end of file + external, + plugins +}));