tiptap/build/packages/config.js

120 lines
3.0 KiB
JavaScript
Raw Normal View History

2018-08-22 16:41:26 +08:00
import path from 'path'
import vue from 'rollup-plugin-vue'
2018-11-12 06:07:24 +08:00
import babel from 'rollup-plugin-babel'
2018-08-22 16:41:26 +08:00
import flow from 'rollup-plugin-flow-no-whitespace'
import cjs from 'rollup-plugin-commonjs'
import node from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
2019-06-13 02:49:07 +08:00
import cssOnly from 'rollup-plugin-css-only'
2018-08-22 16:41:26 +08:00
const resolve = _path => path.resolve(__dirname, '../../', _path)
function genConfig(opts) {
2018-11-12 06:28:07 +08:00
const { version } = require(opts.package)
const banner = `
/*!
* ${opts.name} v${version}
2020-07-23 20:17:50 +08:00
* (c) ${new Date().getFullYear()} überdosis GbR (limited liability)
2018-11-12 06:28:07 +08:00
* @license MIT
*/
`
2018-08-22 16:41:26 +08:00
const config = {
input: {
2018-08-22 17:54:10 +08:00
input: opts.input,
2018-08-22 16:41:26 +08:00
plugins: [
2019-06-13 02:49:07 +08:00
cssOnly({ output: false }),
2018-11-09 05:03:10 +08:00
flow(),
2018-08-22 16:41:26 +08:00
node(),
cjs(),
2018-11-09 05:03:10 +08:00
vue({
css: true,
compileTemplate: true,
}),
2018-08-22 16:41:26 +08:00
replace({
__VERSION__: version,
}),
2018-11-12 06:07:24 +08:00
babel({
exclude: 'node_modules/**',
2018-11-09 05:03:10 +08:00
}),
2018-08-22 17:54:10 +08:00
],
2018-08-26 14:31:43 +08:00
external(id) { return !/^[\.\/]/.test(id) },
2018-08-22 16:41:26 +08:00
},
output: {
file: opts.file,
format: opts.format,
banner,
2019-05-01 00:35:33 +08:00
name: opts.outputName,
2018-11-09 05:03:10 +08:00
},
2018-08-22 16:41:26 +08:00
}
if (opts.env) {
config.input.plugins.unshift(replace({
'process.env.NODE_ENV': JSON.stringify(opts.env),
}))
}
return config
}
export default [
2018-08-23 17:23:03 +08:00
{
2018-08-26 17:55:52 +08:00
package: 'tiptap',
2019-05-01 00:35:33 +08:00
outputName: 'tiptap',
2018-08-26 17:55:52 +08:00
outputFileName: 'tiptap',
2018-08-23 17:23:03 +08:00
},
{
2018-08-26 17:55:52 +08:00
package: 'tiptap-commands',
2019-05-01 00:35:33 +08:00
outputName: 'tiptapCommands',
2018-08-26 17:55:52 +08:00
outputFileName: 'commands',
2018-08-23 17:23:03 +08:00
},
{
2018-08-26 17:55:52 +08:00
package: 'tiptap-utils',
2019-05-01 00:35:33 +08:00
outputName: 'tiptapUtils',
2018-08-26 17:55:52 +08:00
outputFileName: 'utils',
2018-08-23 17:23:03 +08:00
},
{
2018-08-26 17:55:52 +08:00
package: 'tiptap-extensions',
2019-05-01 00:35:33 +08:00
outputName: 'tiptapExtensions',
2018-08-26 17:55:52 +08:00
outputFileName: 'extensions',
2018-08-23 17:23:03 +08:00
},
2018-08-26 17:55:52 +08:00
].map(item => [
2018-08-23 17:23:03 +08:00
{
2018-11-12 06:28:07 +08:00
name: item.package,
2019-05-01 00:35:33 +08:00
outputName: item.outputName,
2018-11-12 06:28:07 +08:00
package: resolve(`packages/${item.package}/package.json`),
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.js`),
2018-08-24 04:09:38 +08:00
format: 'umd',
env: 'development',
},
{
2018-11-12 06:28:07 +08:00
name: item.package,
2019-05-01 00:35:33 +08:00
outputName: item.outputName,
2018-11-12 06:28:07 +08:00
package: resolve(`packages/${item.package}/package.json`),
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.min.js`),
2018-08-24 04:09:38 +08:00
format: 'umd',
env: 'production',
},
{
2018-11-12 06:28:07 +08:00
name: item.package,
2019-05-01 00:35:33 +08:00
outputName: item.outputName,
2018-11-12 06:28:07 +08:00
package: resolve(`packages/${item.package}/package.json`),
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.common.js`),
2018-08-24 04:09:38 +08:00
format: 'cjs',
},
{
2018-11-12 06:28:07 +08:00
name: item.package,
2019-05-01 00:35:33 +08:00
outputName: item.outputName,
2018-11-12 06:28:07 +08:00
package: resolve(`packages/${item.package}/package.json`),
2018-08-26 17:55:52 +08:00
input: resolve(`packages/${item.package}/src/index.js`),
file: resolve(`packages/${item.package}/dist/${item.outputFileName}.esm.js`),
2018-08-24 04:09:38 +08:00
format: 'es',
2018-08-26 17:55:52 +08:00
}])
.reduce((allConfigs, configs) => ([
...allConfigs,
...configs,
]), [])
.map(genConfig)