mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
shrink repetitive rollup.config file
This commit is contained in:
108
rollup.config.js
108
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')
|
||||
})
|
||||
]
|
||||
}
|
||||
];
|
||||
external,
|
||||
plugins
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user