rollup.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import buble from '@rollup/plugin-buble'
  2. import replace from '@rollup/plugin-replace'
  3. import resolve from '@rollup/plugin-node-resolve'
  4. import commonjs from '@rollup/plugin-commonjs'
  5. import { terser } from 'rollup-plugin-terser'
  6. import pkg from './package.json'
  7. const banner = `/*!
  8. * vuex v${pkg.version}
  9. * (c) ${new Date().getFullYear()} Evan You
  10. * @license MIT
  11. */`
  12. export function createEntries(configs) {
  13. return configs.map((c) => createEntry(c))
  14. }
  15. function createEntry(config) {
  16. const c = {
  17. input: config.input,
  18. plugins: [],
  19. output: {
  20. banner,
  21. file: config.file,
  22. format: config.format
  23. },
  24. onwarn: (msg, warn) => {
  25. if (!/Circular/.test(msg)) {
  26. warn(msg)
  27. }
  28. }
  29. }
  30. if (config.format === 'umd') {
  31. c.output.name = c.output.name || 'Vuex'
  32. }
  33. c.plugins.push(replace({
  34. __VERSION__: pkg.version,
  35. __DEV__: config.format !== 'umd' && !config.browser
  36. ? `(process.env.NODE_ENV !== 'production')`
  37. : config.env !== 'production'
  38. }))
  39. if (config.transpile !== false) {
  40. c.plugins.push(buble())
  41. }
  42. c.plugins.push(resolve())
  43. c.plugins.push(commonjs())
  44. if (config.minify) {
  45. c.plugins.push(terser({ module: config.format === 'es' }))
  46. }
  47. return c
  48. }