2021-03-21 22:07:09 +01:00
|
|
|
const analyze = require('rollup-plugin-analyzer');
|
2020-02-14 20:11:24 +01:00
|
|
|
const cleanup = require('rollup-plugin-cleanup');
|
2020-02-20 15:41:47 +01:00
|
|
|
const json = require('@rollup/plugin-json');
|
2020-06-05 01:51:34 +02:00
|
|
|
const resolve = require('@rollup/plugin-node-resolve').default;
|
2020-02-21 00:19:59 +01:00
|
|
|
const terser = require('rollup-plugin-terser').terser;
|
2018-12-14 20:20:43 +01:00
|
|
|
const pkg = require('./package.json');
|
|
|
|
|
2019-03-03 15:19:11 +01:00
|
|
|
const input = 'src/index.js';
|
2020-02-14 18:29:33 +01:00
|
|
|
|
2018-12-14 20:20:43 +01:00
|
|
|
const banner = `/*!
|
|
|
|
* Chart.js v${pkg.version}
|
|
|
|
* ${pkg.homepage}
|
2019-12-07 16:41:56 +01:00
|
|
|
* (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} Chart.js Contributors
|
2018-12-14 20:20:43 +01:00
|
|
|
* Released under the MIT License
|
|
|
|
*/`;
|
|
|
|
|
|
|
|
module.exports = [
|
2021-02-17 14:11:40 +01:00
|
|
|
// UMD builds
|
|
|
|
// dist/chart.min.js
|
|
|
|
// dist/chart.js
|
|
|
|
{
|
|
|
|
input,
|
|
|
|
plugins: [
|
|
|
|
json(),
|
|
|
|
resolve(),
|
|
|
|
cleanup({
|
2022-08-04 15:17:40 +02:00
|
|
|
comments: ['some', /__PURE__/],
|
2021-02-17 14:11:40 +01:00
|
|
|
sourcemap: true
|
2021-03-11 22:20:54 +01:00
|
|
|
}),
|
2021-03-21 22:07:09 +01:00
|
|
|
analyze({summaryOnly: true})
|
2021-02-17 14:11:40 +01:00
|
|
|
],
|
|
|
|
output: {
|
|
|
|
name: 'Chart',
|
|
|
|
file: 'dist/chart.js',
|
|
|
|
banner,
|
|
|
|
format: 'umd',
|
|
|
|
indent: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input,
|
|
|
|
plugins: [
|
|
|
|
json(),
|
|
|
|
resolve(),
|
|
|
|
terser({
|
|
|
|
output: {
|
|
|
|
preamble: banner
|
|
|
|
}
|
2021-03-11 22:20:54 +01:00
|
|
|
}),
|
2021-02-17 14:11:40 +01:00
|
|
|
],
|
|
|
|
output: {
|
|
|
|
name: 'Chart',
|
|
|
|
file: 'dist/chart.min.js',
|
|
|
|
format: 'umd',
|
|
|
|
indent: false,
|
|
|
|
},
|
|
|
|
},
|
2020-02-14 18:29:33 +01:00
|
|
|
|
2021-02-17 14:11:40 +01:00
|
|
|
// ES6 builds
|
2022-07-30 17:25:23 +02:00
|
|
|
// dist/chart.mjs
|
|
|
|
// helpers/*.js
|
|
|
|
{
|
|
|
|
input: {
|
|
|
|
'dist/chart': 'src/index.esm.js',
|
|
|
|
'dist/helpers': 'src/helpers/index.js'
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
json(),
|
|
|
|
resolve(),
|
|
|
|
cleanup({
|
|
|
|
sourcemap: true
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
output: {
|
|
|
|
dir: './',
|
|
|
|
chunkFileNames: 'dist/chunks/[name].mjs',
|
|
|
|
entryFileNames: '[name].mjs',
|
|
|
|
banner,
|
|
|
|
format: 'esm',
|
|
|
|
indent: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Legacy ES6 builds for backwards compatibility. Remove for Chart.js 4.0
|
2021-02-17 14:11:40 +01:00
|
|
|
// dist/chart.esm.js
|
|
|
|
// helpers/*.js
|
|
|
|
{
|
2022-07-30 17:25:23 +02:00
|
|
|
input: {
|
|
|
|
'dist/chart.esm': 'src/index.esm.js',
|
|
|
|
'dist/helpers.esm': 'src/helpers/index.js'
|
|
|
|
},
|
2021-02-17 14:11:40 +01:00
|
|
|
plugins: [
|
|
|
|
json(),
|
|
|
|
resolve(),
|
|
|
|
cleanup({
|
2022-08-04 15:17:40 +02:00
|
|
|
comments: ['some', /__PURE__/],
|
2021-02-17 14:11:40 +01:00
|
|
|
sourcemap: true
|
2021-03-11 22:20:54 +01:00
|
|
|
}),
|
2021-02-17 14:11:40 +01:00
|
|
|
],
|
|
|
|
output: {
|
|
|
|
dir: './',
|
|
|
|
chunkFileNames: 'dist/chunks/[name].js',
|
|
|
|
banner,
|
|
|
|
format: 'esm',
|
|
|
|
indent: false,
|
|
|
|
},
|
|
|
|
},
|
2018-12-14 20:20:43 +01:00
|
|
|
];
|