config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const uglifyPlugin = require('rollup-plugin-uglify');
  2. const {resolve} = require('path');
  3. // Based on echarts/
  4. function getPath(relativePath) {
  5. return resolve(__dirname, '../', relativePath);
  6. }
  7. /**
  8. * @param {boolean} [min=false]
  9. */
  10. function getPlugins(min) {
  11. let plugins = [];
  12. min && plugins.push(uglifyPlugin({
  13. compress: {
  14. // Eliminate __DEV__ code.
  15. 'global_defs': {
  16. __DEV__: true
  17. }
  18. }
  19. }));
  20. return plugins;
  21. }
  22. /**
  23. * @param {boolean} [min=false]
  24. */
  25. exports.create = function (min) {
  26. let postfixMin = min ? '.min' : '';
  27. return {
  28. plugins: getPlugins(min),
  29. input: getPath(`./zrender.all.js`),
  30. legacy: true, // Support IE8-
  31. output: {
  32. name: 'zrender',
  33. format: 'umd',
  34. legacy: true, // Must be declared both in inputOptions and outputOptions.
  35. sourcemap: !min,
  36. file: getPath(`dist/zrender${postfixMin}.js`)
  37. },
  38. watch: {
  39. include: [getPath('./src/**'), getPath('./zrender*.js')]
  40. }
  41. };
  42. };