mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-21 06:45:00 +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'
|
'sapper/core.js': './core.js'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const plugins = [
|
||||||
|
typescript({
|
||||||
|
typescript: require('typescript')
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
// cli.js
|
{ name: 'cli', banner: true },
|
||||||
{
|
{ name: 'core', banner: true },
|
||||||
input: 'src/cli/index.ts',
|
{ name: 'middleware' },
|
||||||
output: {
|
{ name: 'runtime', format: 'es' },
|
||||||
file: 'cli.js',
|
{ name: 'webpack', file: 'webpack/config' }
|
||||||
format: 'cjs',
|
].map(obj => ({
|
||||||
banner: '#!/usr/bin/env node',
|
input: `src/${obj.name}/index.ts`,
|
||||||
paths,
|
output: {
|
||||||
sourcemap: true
|
file: `${obj.file || obj.name}.js`,
|
||||||
},
|
format: obj.format || 'cjs',
|
||||||
external,
|
banner: obj.banner && '#!/usr/bin/env node',
|
||||||
plugins: [
|
paths,
|
||||||
typescript({
|
sourcemap: true
|
||||||
typescript: require('typescript')
|
|
||||||
})
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
external,
|
||||||
// core.js
|
plugins
|
||||||
{
|
}));
|
||||||
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')
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|||||||
Reference in New Issue
Block a user