threepipe
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

rollup.config.mjs 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // rollup.config.js
  2. import commonjs from '@rollup/plugin-commonjs';
  3. import json from '@rollup/plugin-json';
  4. import resolve from '@rollup/plugin-node-resolve';
  5. import typescript from '@rollup/plugin-typescript';
  6. import license from 'rollup-plugin-license'
  7. import packageJson from './package.json' assert {type: 'json'};
  8. import path from 'path'
  9. import {fileURLToPath} from 'url';
  10. import postcss from 'rollup-plugin-postcss'
  11. import glsl from "rollup-plugin-glsl"
  12. import replace from "@rollup/plugin-replace";
  13. import terser from "@rollup/plugin-terser";
  14. const __filename = fileURLToPath(import.meta.url);
  15. const __dirname = path.dirname(__filename);
  16. const {name, version, author} = packageJson
  17. const {main, module, browser} = packageJson["clean-package"].replace
  18. const isProduction = process.env.NODE_ENV === 'production'
  19. const settings = {
  20. globals: {},
  21. sourcemap: true
  22. }
  23. export default {
  24. input: './src/index.ts',
  25. output: [
  26. // {
  27. // file: main,
  28. // name: main,
  29. // ...settings,
  30. // format: 'cjs',
  31. // plugins: [
  32. // isProduction && terser()
  33. // ]
  34. // },
  35. {
  36. file: module,
  37. ...settings,
  38. name: name,
  39. // dir: 'dist', // indicate not create a single-file
  40. // preserveModules: true, // indicate not create a single-file
  41. // preserveModulesRoot: 'src', // optional but useful to create a more plain folder structure
  42. format: 'es'
  43. },
  44. {
  45. file: browser,
  46. ...settings,
  47. name: name,
  48. format: 'umd',
  49. plugins: [
  50. isProduction && terser()
  51. ]
  52. }
  53. ],
  54. external: [],
  55. plugins: [
  56. replace({
  57. 'process.env.NODE_ENV': JSON.stringify( 'production' ),
  58. }),
  59. // replace({
  60. // exclude: 'src/**',
  61. // delimiters: ['', ''],
  62. // values:{
  63. // 'from \'three\'': 'from \'threepipe\'',
  64. // },
  65. // }),
  66. glsl({ // todo: minify glsl.
  67. include: "src/**/*.glsl"
  68. }),
  69. postcss({
  70. modules: false,
  71. autoModules: true, // todo; issues with typescript import css, because inject is false
  72. inject: false,
  73. minimize: isProduction,
  74. // Or with custom options for `postcss-modules`
  75. }),
  76. json(),
  77. resolve({}),
  78. typescript({}),
  79. commonjs({
  80. include: 'node_modules/**',
  81. extensions: ['.js'],
  82. ignoreGlobal: false,
  83. sourceMap: false
  84. }),
  85. license({
  86. banner: `
  87. @license
  88. ${name} v${version}
  89. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  90. ${packageJson.license} License
  91. `,
  92. thirdParty: {
  93. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  94. includePrivate: true, // Default is false.
  95. },
  96. })
  97. ]
  98. }