rollup.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* eslint-env es6 */
  2. const commonjs = require('rollup-plugin-commonjs');
  3. const resolve = require('rollup-plugin-node-resolve');
  4. const terser = require('rollup-plugin-terser').terser;
  5. const optional = require('./rollup.plugins').optional;
  6. const stylesheet = require('./rollup.plugins').stylesheet;
  7. const pkg = require('./package.json');
  8. const input = 'src/index.js';
  9. const banner = `/*!
  10. * Chart.js v${pkg.version}
  11. * ${pkg.homepage}
  12. * (c) ${new Date().getFullYear()} Chart.js Contributors
  13. * Released under the MIT License
  14. */`;
  15. module.exports = [
  16. // UMD builds (excluding moment)
  17. // dist/Chart.min.js
  18. // dist/Chart.js
  19. {
  20. input: input,
  21. plugins: [
  22. resolve(),
  23. commonjs(),
  24. stylesheet({
  25. extract: true
  26. }),
  27. optional({
  28. include: ['moment']
  29. })
  30. ],
  31. output: {
  32. name: 'Chart',
  33. file: 'dist/Chart.js',
  34. banner: banner,
  35. format: 'umd',
  36. indent: false,
  37. globals: {
  38. moment: 'moment'
  39. }
  40. },
  41. external: [
  42. 'moment'
  43. ]
  44. },
  45. {
  46. input: input,
  47. plugins: [
  48. resolve(),
  49. commonjs(),
  50. optional({
  51. include: ['moment']
  52. }),
  53. stylesheet({
  54. extract: true,
  55. minify: true
  56. }),
  57. terser({
  58. output: {
  59. preamble: banner
  60. }
  61. })
  62. ],
  63. output: {
  64. name: 'Chart',
  65. file: 'dist/Chart.min.js',
  66. format: 'umd',
  67. indent: false,
  68. globals: {
  69. moment: 'moment'
  70. }
  71. },
  72. external: [
  73. 'moment'
  74. ]
  75. },
  76. // UMD builds (including moment)
  77. // dist/Chart.bundle.min.js
  78. // dist/Chart.bundle.js
  79. {
  80. input: input,
  81. plugins: [
  82. resolve(),
  83. commonjs(),
  84. stylesheet()
  85. ],
  86. output: {
  87. name: 'Chart',
  88. file: 'dist/Chart.bundle.js',
  89. banner: banner,
  90. format: 'umd',
  91. indent: false
  92. }
  93. },
  94. {
  95. input: input,
  96. plugins: [
  97. resolve(),
  98. commonjs(),
  99. stylesheet({
  100. minify: true
  101. }),
  102. terser({
  103. output: {
  104. preamble: banner
  105. }
  106. })
  107. ],
  108. output: {
  109. name: 'Chart',
  110. file: 'dist/Chart.bundle.min.js',
  111. format: 'umd',
  112. indent: false
  113. }
  114. }
  115. ];