-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.mjs
94 lines (87 loc) · 3.41 KB
/
rollup.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
import resolve from '@rollup/plugin-node-resolve';
import pkg from './package.json' assert { type: 'json' };
import json from '@rollup/plugin-json';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
import replace from '@rollup/plugin-replace';
import postcss from 'rollup-plugin-postcss';
import { visualizer } from 'rollup-plugin-visualizer';
const PRODUCTION = process.env.NODE_ENV === 'production';
const comfortReactGlobals = {
'date-fns/locale/tr': 'date-fns/locale/tr',
'date-fns/locale/en-US': 'date-fns/locale/en-US',
'@mui/icons-material': '@mui/icons-material',
'@mui/lab': '@mui/lab',
'@mui/material': '@mui/material',
'@mui/x-date-pickers': '@mui/x-date-pickers',
'@mui/x-date-pickers/AdapterDateFns': '@mui/x-date-pickers/AdapterDateFns',
react: 'react',
'react-dom': 'react-dom',
'react-draggable': 'react-draggable',
'react-dropzone': 'react-dropzone',
'react-imask': 'react-imask',
'react-phone-input-2': 'react-phone-input-2',
'react-phone-input-2/lang/tr.json': 'react-phone-input-2/lang/tr.json',
};
export default {
input: 'src/lib/index.js',
output: [
{
file: pkg.module,
format: 'esm',
globals: comfortReactGlobals,
},
{
file: pkg.main,
format: 'umd',
globals: comfortReactGlobals,
name: 'index.js',
},
],
plugins: [
replace({
preventAssignment: false,
'process.env.NODE_ENV': JSON.stringify(PRODUCTION ? 'production' : 'development'),
}),
external(),
babel({
babelrc: false,
babelHelpers: 'bundled',
exclude: 'node_modules/**',
plugins: ['@babel/plugin-proposal-function-bind', '@babel/plugin-proposal-class-properties'],
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-react'],
}),
resolve({
mainFields: ['browser', 'jsnext', 'module', 'main'],
}),
postcss({
extensions: ['.css'],
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**', // Default: undefined
// these values can also be regular expressions
// include: /node_modules/
// search for files other than .js files (must already
// be transpiled by a previous plugin!)
extensions: ['.js', '.jsx', '.coffee'], // Default: [ '.js' ]
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false, // Default: false
// if false then skip sourceMap generation for CommonJS modules
sourceMap: false, // Default: true
// sometimes you have to leave require statements
// unconverted. Pass an array containing the IDs
// or a `id => boolean` function. Only use this
// option if you know what you're doing!
ignore: ['conditional-runtime-dependency'],
}),
json(),
globals(),
builtins(),
PRODUCTION ? visualizer({ gzipSize: true }) : null,
],
};