rollup.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const fs = require('fs-extra')
  2. const path = require('path')
  3. const babel = require('rollup-plugin-babel');
  4. const { uglify } = require('rollup-plugin-uglify');
  5. const PATH = `./.laser-lib-path`
  6. const buildPaths = [
  7. `build`,
  8. ...fs.existsSync(PATH) ? [fs.readFileSync(PATH).toString()] : []
  9. ]
  10. const builds = []
  11. for (const dir of buildPaths) {
  12. console.log(`${dir}/potree/potree.js`)
  13. builds.push(
  14. ...[
  15. {
  16. input: 'src/Potree.js',
  17. treeshake: false,
  18. output: {
  19. file: `${dir}/potree/potree.js`,
  20. format: 'umd',
  21. name: 'Potree',
  22. sourcemap: true,
  23. }
  24. }, {
  25. input: 'src/workers/BinaryDecoderWorker.js',
  26. output: {
  27. file: `${dir}/potree/workers/BinaryDecoderWorker.js`,
  28. format: 'es',
  29. name: 'Potree',
  30. sourcemap: false
  31. }
  32. },{
  33. input: 'src/modules/loader/2.0/DecoderWorker.js',
  34. output: {
  35. file: `${dir}/potree/workers/2.0/DecoderWorker.js`,
  36. format: 'es',
  37. name: 'Potree',
  38. sourcemap: false
  39. }
  40. },{
  41. input: 'src/modules/loader/2.0/DecoderWorker_brotli.js',
  42. output: {
  43. file: `${dir}/potree/workers/2.0/DecoderWorker_brotli.js`,
  44. format: 'es',
  45. name: 'Potree',
  46. sourcemap: false
  47. }
  48. }
  49. ]
  50. )
  51. }
  52. if (process.env.npm_lifecycle_script.includes('production')) {
  53. builds.forEach(item => {
  54. item.output.sourcemap = false
  55. item.plugins = [
  56. babel({
  57. exclude: "node_modules/**"
  58. }),
  59. // 压缩代码
  60. uglify()
  61. ]
  62. })
  63. }
  64. export default builds