rollup.config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import babel from '@rollup/plugin-babel';
  2. import external from 'rollup-plugin-peer-deps-external';
  3. import del from 'rollup-plugin-delete';
  4. import pkg from './package.json';
  5. import commonjs from 'rollup-plugin-commonjs';
  6. import postcss from 'rollup-plugin-postcss';
  7. // import ascii from "rollup-plugin-ascii";
  8. import resolve from '@rollup/plugin-node-resolve';
  9. import { terser } from 'rollup-plugin-terser';
  10. const peerDependencies = [
  11. '@ant-design/compatible',
  12. '@ant-design/icons',
  13. 'antd',
  14. 'brace',
  15. 'form-render',
  16. 'moox',
  17. 'react',
  18. 'react-dom',
  19. 'react-redux',
  20. 'redux',
  21. 'lodash',
  22. 'prop-types',
  23. /^antd\/.+$/,
  24. /^form-render\/.+$/,
  25. /^@ant-design\/.+$/,
  26. ];
  27. export default {
  28. input: pkg.source,
  29. output: [
  30. // { file: pkg.main, format: 'cjs' },
  31. // { file: pkg.module, format: 'esm' },
  32. { file: pkg.common, format: 'umd', name: 'SchemaForm' },
  33. ],
  34. plugins: [
  35. resolve(),
  36. external(),
  37. babel({
  38. exclude: 'node_modules/**',
  39. }),
  40. commonjs({
  41. include: 'node_modules/**',
  42. namedExports: {
  43. 'node_modules/react-is/index.js': ['isFragment', 'ForwardRef', 'isValidElementType', 'isMemo'],
  44. },
  45. }),
  46. // ascii(),
  47. postcss({
  48. // Extract CSS to the same location where JS file is generated but with .css extension.
  49. extract: true,
  50. // Use named exports alongside default export.
  51. namedExports: true,
  52. // Minimize CSS, boolean or options for cssnano.
  53. minimize: true,
  54. // Enable sourceMap.
  55. sourceMap: false,
  56. // This plugin will process files ending with these extensions and the extensions supported by custom loaders.
  57. extensions: ['.less', '.css'],
  58. use: ['sass', ['less', { javascriptEnabled: true }]],
  59. }),
  60. terser(),
  61. del({ targets: ['dist/*'] }),
  62. ],
  63. external: peerDependencies,
  64. };