Skip to content

Commit

Permalink
build(rollup): remove node-resolve config
Browse files Browse the repository at this point in the history
  • Loading branch information
mkosir committed May 8, 2022
1 parent 01999aa commit 59b3904
Showing 1 changed file with 62 additions and 48 deletions.
110 changes: 62 additions & 48 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,79 @@ import commonjs from '@rollup/plugin-commonjs';
import image from '@rollup/plugin-image';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';
import dts from 'rollup-plugin-dts';
//@ts-ignore types package is broken - https://www.npmjs.com/package/@types/rollup-plugin-size-snapshot
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import { terser } from 'rollup-plugin-terser';
import visualizer from 'rollup-plugin-visualizer';

import packageJson from './package.json';
import tsConfig from './tsconfig.base.json';

const isProduction = process.env.NODE_ENV === 'production';

const rollupConfig = defineConfig({
input: `src/index.ts`,
output: [
{
file: packageJson.module,
format: 'esm',
sourcemap: !isProduction,
},
{
file: packageJson.main,
name: packageJson.name,
format: 'umd',
sourcemap: !isProduction,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react-tabs': 'react-tabs',
'react-syntax-highlighter': 'react-syntax-highlighter',
const rollupConfig = defineConfig([
{
input: `src/index.ts`,
output: [
{
file: packageJson.main,
name: packageJson.name,
format: 'umd',
sourcemap: !isProduction,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react-tabs': 'react-tabs',
'react-syntax-highlighter': 'react-syntax-highlighter',
},
},
},
],
plugins: [
commonjs(),
typescript({
tsconfig: './tsconfig.prod.json',
declaration: true,
declarationDir: 'types',
}),
sizeSnapshot({ matchSnapshot: Boolean(process.env.MATCH_SNAPSHOT) }),
terser({
output: { comments: false },
compress: {
pure_getters: true,
{
file: packageJson.module,
format: 'esm',
sourcemap: !isProduction,
},
// Compress and/or mangle variables in top level scope.
toplevel: true,
}),
image(),
visualizer({
filename: 'bundle-analysis.html',
title: `${packageJson.name} - Rollup Visualizer`,
open: false,
}),
],
// Ensure dependencies are not bundled with the library
external: [
//...Object.keys(packageJson.dependencies || {}),
...Object.keys(packageJson.peerDependencies || {}),
],
});
],
plugins: [
sizeSnapshot({ matchSnapshot: Boolean(process.env.MATCH_SNAPSHOT) }),
commonjs(),
typescript({
tsconfig: './tsconfig.prod.json',
}),
terser({
output: { comments: false },
compress: {
pure_getters: true,
},
// Compress and/or mangle variables in top level scope.
toplevel: true,
}),
image(),
visualizer({
filename: 'bundle-analysis.html',
title: `${packageJson.name} - Rollup Visualizer`,
open: false,
}),
],
// Ensure dependencies are not bundled with the library
external: [
//...Object.keys(packageJson.dependencies || {}),
...Object.keys(packageJson.peerDependencies || {}),
],
},
{
input: 'src/index.ts',
output: { file: packageJson.types, format: 'esm' },
plugins: [
dts({
compilerOptions: {
baseUrl: tsConfig.compilerOptions.baseUrl,
paths: tsConfig.compilerOptions.paths,
},
}),
],
},
]);

// eslint-disable-next-line
export default rollupConfig;

0 comments on commit 59b3904

Please sign in to comment.