Skip to content

Instantly share code, notes, and snippets.

@sirtimbly
Created December 15, 2018 04:06
Show Gist options
  • Save sirtimbly/6484e618740733afdfa6bc9d9a6084c2 to your computer and use it in GitHub Desktop.
Save sirtimbly/6484e618740733afdfa6bc9d9a6084c2 to your computer and use it in GitHub Desktop.
rollup config for typescript with multiple configs
import typescript from 'rollup-plugin-typescript2';
import { terser } from "rollup-plugin-terser";
import { sizeSnapshot } from "rollup-plugin-size-snapshot";
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import * as globby from "globby";
const globbedConfigs = globby.sync('src/patterns/**/*.ts').map(inputFile => {
const filename = inputFile.split("/")[inputFile.split("/").length-1];
return {
input: inputFile,
output: {
dir: './public/js/',
format: 'iife',
file: filename.replace(".ts", ".min.js"),
name: filename.replace(".ts", ""),
},
plugins: [
resolve(),
commonjs(),
typescript(),
sizeSnapshot(),
terser()
]
};
});
export default [...globbedConfigs,{
input: './src/scripts/main.ts',
output: [{
format: 'iife',
dir: './public/js/',
file: 'main.browser.js',
name: 'com.compassion',
sourcemap: true,
}],
plugins: [
resolve(),
commonjs(),
typescript(/*{ plugin options }*/),
sizeSnapshot(),
]
},{
input: './src/scripts/main.ts',
output: [{
format: 'iife',
dir: './public/js/',
file: 'main.browser.min.js',
name: 'com.compassion',
}],
plugins: [
resolve(),
commonjs(),
typescript(/*{ plugin options }*/),
sizeSnapshot(),
terser()
]
},{
input: './src/scripts/main.ts',
output: {
format: "es",
dir: "./dist/js/",
file: "main.module.js",
sourcemap: true,
},
plugins: [
resolve({
browser: true,
}),
commonjs(),
typescript(/*{ plugin options }*/),
sizeSnapshot(),
]
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment