Chart.js/rollup.config.js
Chris Lamb c4483d1864 Make the build reproducible (#6817)
Whilst working on the Reproducible Builds effort [0] we noticed that
Chart.js could not be built reproducibly.

This is because it was embedding another build date in a "banner"
comment. This patch uses the value from SOURCE_DATE_EPOCH [1] if
present.

This was originally filed in Debian as #946333 [2].

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/
 [2] https://bugs.debian.org/946333

Signed-off-by: Chris Lamb <lamby@debian.org>
2019-12-07 10:41:56 -05:00

147 lines
2.4 KiB
JavaScript

/* eslint-env es6 */
const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve');
const babel = require('rollup-plugin-babel');
const terser = require('rollup-plugin-terser').terser;
const optional = require('./rollup.plugins').optional;
const stylesheet = require('./rollup.plugins').stylesheet;
const pkg = require('./package.json');
const input = 'src/index.js';
const banner = `/*!
* Chart.js v${pkg.version}
* ${pkg.homepage}
* (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} Chart.js Contributors
* Released under the MIT License
*/`;
module.exports = [
// ES6 builds
// dist/Chart.esm.min.js
// dist/Chart.esm.js
{
input: input,
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**'
}),
stylesheet({
extract: true
}),
],
output: {
name: 'Chart',
file: 'dist/Chart.esm.js',
banner: banner,
format: 'esm',
indent: false,
globals: {
moment: 'moment'
}
},
external: [
'moment'
]
},
{
input: input,
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**'
}),
stylesheet({
extract: true,
minify: true
}),
terser({
output: {
preamble: banner
}
})
],
output: {
name: 'Chart',
file: 'dist/Chart.esm.min.js',
format: 'esm',
indent: false,
globals: {
moment: 'moment'
}
},
external: [
'moment'
]
},
// UMD builds
// dist/Chart.min.js
// dist/Chart.js
{
input: input,
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**'
}),
stylesheet({
extract: true
}),
optional({
include: ['moment']
})
],
output: {
name: 'Chart',
file: 'dist/Chart.js',
banner: banner,
format: 'umd',
indent: false,
globals: {
moment: 'moment'
}
},
external: [
'moment'
]
},
{
input: input,
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**'
}),
optional({
include: ['moment']
}),
stylesheet({
extract: true,
minify: true
}),
terser({
output: {
preamble: banner
}
})
],
output: {
name: 'Chart',
file: 'dist/Chart.min.js',
format: 'umd',
indent: false,
globals: {
moment: 'moment'
}
},
external: [
'moment'
]
}
];