Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plugins: [
nodeResolve({
mainFields: ['module', 'jsnext', 'main'],
browser: format !== 'cjs',
}),
format === 'umd' &&
commonjs({
include: /\/node_modules\//,
}),
json(),
babel(babelOptions(format)),
replace({
'process.env.NODE_ENV': JSON.stringify(env),
}),
sourceMaps(),
sizeSnapshot({
printInfo: false,
}),
env === 'production' &&
terser({
sourcemap: true,
output: { comments: false },
compress: {
keep_infinity: true,
pure_getters: true,
// collapse_vars: false,
},
ecma: 5,
toplevel: format === 'es' || format === 'cjs',
warnings: true,
}),
],
const getPlugins = () => ({
babel: babel({// runtimeHelpers: true,
// exclude: /(\.re|node_modules.*)/,
}),
replace: replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
commonjs: commonjs({}),
resolve: resolve({}),
terser: rollupPluginTerser.terser(minifyConfig({
prettify: !!process.env.PRETTIFY
})),
sizeSnapshot: rollupPluginSizeSnapshot.sizeSnapshot(),
graph: plugin({
output: 'modules.dot'
})
});
commonjs(),
babel({
runtimeHelpers: true,
exclude: ['node_modules/**', 'packages/**/node_modules/**'],
presets: [['@babel/env', { modules: false }]],
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'],
}),
svgo({
raw: true,
}),
replace({
exclude: 'node_modules/**',
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
__VERSION__: version,
}),
isProd && sizeSnapshot(),
isProd && removeHtmlSpace(),
isProd &&
terser({
output: {
preamble: banner,
comments: function() {
return false;
},
},
}),
isProd &&
copyAfterBuild({
from: path.join(projectPath, 'dist/*'),
to: path.join(process.cwd(), 'dist'),
}),
],
function createConfig(entry, out, name) {
return [
{
input: `./src/${entry}.js`,
output: { file: `dist/${out}.es.js`, format: 'es' },
external: isExternal,
plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()],
},
{
input: `./src/${entry}.js`,
output: { file: `dist/${out}.cjs.js`, format: 'cjs' },
external: isExternal,
plugins: [babel(getBabelOptions({ useESModules: false }))],
},
{
input: `./src/${entry}.js`,
output: {
file: `dist/${out}.umd.js`,
format: 'umd',
name,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
function createConfig(entry, out) {
return [
{
input: `./src/${entry}`,
output: { file: `dist/${out}.js`, format: 'esm' },
external,
plugins: [
json(),
babel(getBabelOptions({ useESModules: true }, '>1%, not dead, not ie 11, not op_mini all')),
sizeSnapshot(),
resolve({ extensions }),
],
},
{
input: `./src/${entry}`,
output: { file: `dist/${out}.cjs.js`, format: 'cjs' },
external,
plugins: [json(), babel(getBabelOptions({ useESModules: false })), sizeSnapshot(), resolve({ extensions })],
},
]
}
function createConfig(entry, out) {
return [
{
input: `./src/${entry}/index`,
output: { file: `dist/${out}.js`, format: 'esm' },
external,
plugins: [
babel(
getBabelOptions(
{ useESModules: true },
'>1%, not dead, not ie 11, not op_mini all'
)
),
sizeSnapshot(),
resolve({ extensions }),
],
},
{
input: `./src/${entry}/index`,
output: { file: `dist/${out}.cjs.js`, format: 'cjs' },
external,
plugins: [
babel(getBabelOptions({ useESModules: false })),
sizeSnapshot(),
resolve({ extensions }),
],
},
]
}
const getPlugins = (name: string) => ({
babel: babel({
runtimeHelpers: false,
exclude: /(\.re|node_modules.*)/,
}),
replace: replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
commonjs: commonjs({}),
resolve: resolve({}),
sizeSnapshot: sizeSnapshot({
printInfo: false,
}),
analyzer: analyze({
filename: `stats/${name}.html`,
title: `${name} size report`,
sourcemap: true,
template: 'treemap',
}),
analyzerJSON: analyze({
sourcemap: true,
json: true,
filename: `stats/${name}.json`,
}),
terser: terser(
minifyConfig({
beautify: !!process.env.PRETTIFY,
const typescript = require("rollup-plugin-typescript2");
exports.replaceWithProduction = replace({
"process.env.NODE_ENV": `"production"`
});
exports.replaceWithDevelopment = replace({
"process.env.NODE_ENV": `"development"`
});
exports.resolveNode = resolve();
exports.commonjs = commonjs({
include: /node_modules/
});
exports.sizeSnapshot = sizeSnapshot();
exports.minify = uglify();
exports.typescript = typescript({
useTsconfigDeclarationDir: true
});
exports.replaceWithProduction = replace({
"process.env.NODE_ENV": `"production"`
});
exports.replaceWithDevelopment = replace({
"process.env.NODE_ENV": `"development"`
});
exports.resolveNode = resolve();
exports.commonjs = commonjs({
include: /node_modules/
});
exports.sizeSnapshot = sizeSnapshot();
exports.minify = uglify();
exports.typescript = typescript({
useTsconfigDeclarationDir: true
});
declaration: true,
jsx: 'react',
},
},
tsconfigOverride: {
compilerOptions: {
target: 'esnext',
},
},
}),
babel(babelOptions),
replace({
'process.env.NODE_ENV': JSON.stringify(env),
}),
sourceMaps(),
sizeSnapshot(),
env === 'production' &&
terser({
sourcemap: true,
output: { comments: false },
compress: {
keep_infinity: true,
pure_getters: true,
},
ecma: 5,
toplevel: format === 'es' || format === 'cjs',
warnings: true,
}),
],
};
}