2020-08-02 19:17:06 +02:00
|
|
|
import babel from '@rollup/plugin-babel'
|
|
|
|
import resolve from '@rollup/plugin-node-resolve'
|
|
|
|
import json from '@rollup/plugin-json'
|
|
|
|
import { terser } from 'rollup-plugin-terser'
|
|
|
|
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
|
|
|
|
import { name, version, description, author, license } from './package.json'
|
|
|
|
import utils from './src/index.js'
|
2019-04-27 12:21:14 +02:00
|
|
|
|
2019-07-13 08:48:58 +02:00
|
|
|
const createConfig = (util, module) => {
|
|
|
|
return {
|
2020-08-02 19:17:06 +02:00
|
|
|
input: `./src/${util + '/'}index.js`,
|
2019-07-13 08:48:58 +02:00
|
|
|
output: {
|
2020-08-02 19:17:06 +02:00
|
|
|
file: `./${util}/index` + (module ? '.mjs' : '.js'),
|
|
|
|
format: module ? 'es' : 'cjs',
|
|
|
|
sourcemap: true,
|
|
|
|
exports: 'default'
|
2019-07-13 08:48:58 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
2020-08-02 19:17:06 +02:00
|
|
|
babel({
|
|
|
|
exclude: 'node_modules/**',
|
|
|
|
babelHelpers: 'bundled'
|
|
|
|
}),
|
2019-07-13 08:48:58 +02:00
|
|
|
peerDepsExternal(),
|
|
|
|
resolve({ modulesOnly: true }),
|
|
|
|
json(),
|
2021-05-30 18:27:53 +02:00
|
|
|
//terser({
|
|
|
|
// output: {
|
|
|
|
// preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
|
|
|
|
// }
|
|
|
|
//})
|
2019-07-13 08:48:58 +02:00
|
|
|
]
|
2020-08-02 19:17:06 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-13 08:48:58 +02:00
|
|
|
|
2020-08-02 19:17:06 +02:00
|
|
|
const config = []
|
2019-07-13 08:48:58 +02:00
|
|
|
for (let util of utils) {
|
2020-08-02 19:17:06 +02:00
|
|
|
config.push(createConfig(util, false))
|
2019-07-13 08:48:58 +02:00
|
|
|
// Webpack doesn't handle .mjs very well
|
2021-05-30 18:27:53 +02:00
|
|
|
config.push(createConfig(util, true));
|
2019-07-13 08:48:58 +02:00
|
|
|
}
|
2020-08-02 19:17:06 +02:00
|
|
|
export default config
|