Files
react-content-loader/rollup.config.js
Danilo Woznica 8ed714cb3d V5: API changes (#176)
* feat(api): updates background and foreground

BREAKING CHANGE: Rename `primaryColor` to `backgroundColor` and `secondaryColor` to
`foregroundColor`.

* feat(api): updates uniqueKey

BREAKING CHANGE: Renamed prop key `uniquekey` to `uniqueKey`

* fix(svg): removes unnecessary keys

* fix(web svg): adds display name

* feat(a11y): improves attrs

BREAKING CHANGE: Shift `ariaLabel` to `title` prop, the value remains

* refactor(codebase): reestructure

* test(web native): updates with new structure

* test(native): sets animate false on tests

* fix(svg): removes viewBox, width and height from api

* fix(presets): updates to new api and some design updates

* feat(content loader): sets new default as facebook instead of a box

* docs(readme storybook): updates to new api

* test(web native): updates
2020-01-26 20:06:38 +00:00

130 lines
2.6 KiB
JavaScript

/* eslint-disable @typescript-eslint/camelcase */
import replace from 'rollup-plugin-replace'
import { uglify } from 'rollup-plugin-uglify'
import typescript from 'rollup-plugin-typescript2'
import copy from 'rollup-plugin-copy'
import pkg from './package.json'
const mergeAll = objs => Object.assign({}, ...objs)
const cjs = {
exports: 'named',
format: 'cjs',
sourcemap: true,
}
const esm = {
format: 'es',
sourcemap: true,
}
const globals = { react: 'React', 'react-dom': 'ReactDOM' }
const commonPlugins = [
typescript({
typescript: require('typescript'),
}),
]
const configBase = {
output: {
exports: 'named',
},
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
plugins: commonPlugins,
}
const umdConfig = mergeAll([
configBase,
{
input: 'src/web/index.ts',
output: mergeAll([
configBase.output,
{
file: `dist/${pkg.name}.js`,
format: 'umd',
name: 'ContentLoader',
globals,
},
]),
external: Object.keys(pkg.peerDependencies || {}),
},
])
const devUmdConfig = mergeAll([
umdConfig,
{
input: 'src/web/index.ts',
plugins: umdConfig.plugins.concat(
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
})
),
},
])
const prodUmdConfig = mergeAll([
umdConfig,
{
input: 'src/web/index.ts',
output: mergeAll([
umdConfig.output,
{ file: umdConfig.output.file.replace(/\.js$/, '.min.js') },
]),
},
{
plugins: umdConfig.plugins.concat(
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
},
})
),
},
])
const webConfig = mergeAll([
configBase,
{
input: 'src/web/index.ts',
output: [
mergeAll([configBase.output, { ...esm, file: pkg.module }]),
mergeAll([configBase.output, { ...cjs, file: pkg.main }]),
],
plugins: configBase.plugins.concat(),
},
])
const nativeConfig = mergeAll([
configBase,
{
input: './src/native/index.ts',
output: [
mergeAll([
configBase.output,
{ ...esm, file: `native/${pkg.name}.native.es.js` },
]),
mergeAll([
configBase.output,
{ ...cjs, file: `native/${pkg.name}.native.cjs.js` },
]),
],
plugins: configBase.plugins.concat(
copy({
targets: [{ src: 'src/native/package.json', dest: 'native' }],
})
),
},
])
export default [devUmdConfig, prodUmdConfig, webConfig, nativeConfig]