2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-14 14:38:25 +00:00
iconify/archive/react-with-api/rollup.config.js
2021-04-23 15:51:09 +03:00

84 lines
1.4 KiB
JavaScript

import { writeFileSync, mkdirSync } from 'fs';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import buble from '@rollup/plugin-buble';
import { terser } from 'rollup-plugin-terser';
const name = 'icon';
// Write main file
const text = `'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./${name}.cjs.production.js')
} else {
module.exports = require('./${name}.cjs.development.js')
}
`;
try {
mkdirSync('dist', 0o755);
} catch (err) {}
writeFileSync(`dist/${name}.js`, text, 'utf8');
// Export configuration
const config = [
// Module
{
input: `lib/${name}.js`,
output: [
{
file: `dist/${name}.esm.js`,
format: 'esm',
},
],
external: ['react', 'axios'],
plugins: [
resolve(),
commonjs({
ignore: ['cross-fetch'],
}),
buble(),
],
},
// Dev build
{
input: `lib/${name}.js`,
output: [
{
file: `dist/${name}.cjs.development.js`,
format: 'cjs',
},
],
external: ['react', 'axios'],
plugins: [
resolve(),
commonjs({
ignore: ['cross-fetch'],
}),
buble(),
],
},
// Production
{
input: `lib/${name}.js`,
output: [
{
file: `dist/${name}.cjs.production.js`,
format: 'cjs',
},
],
external: ['react', 'axios'],
plugins: [
resolve(),
commonjs({
ignore: ['cross-fetch'],
}),
buble(),
terser(),
],
},
];
export default config;