説明なし

vite.config.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. import { defineConfig } from "vite";
  2. import { viteStaticCopy } from 'vite-plugin-static-copy';
  3. import { svelte } from '@sveltejs/vite-plugin-svelte'
  4. import fs from "node:fs";
  5. import path from "node:path";
  6. import { fileURLToPath } from "node:url";
  7. function resolveInputs(directory) {
  8. const inputs = fs
  9. .readdirSync(directory, { withFileTypes: true, })
  10. .reduce((acc, entry) => {
  11. if (entry.isFile()) {
  12. const file = entry.name;
  13. const filename = path.parse(file).name;
  14. const filepath = path.join(directory, file);
  15. acc[filename] = fileURLToPath(new URL(filepath, import.meta.url));
  16. } else {
  17. const subDirectory = entry.name;
  18. const filepath = path.join(directory, subDirectory, 'index.js');
  19. if (fs.existsSync(filepath)) {
  20. acc[subDirectory] = fileURLToPath(new URL(filepath, import.meta.url));
  21. }
  22. }
  23. return acc;
  24. }, {});
  25. return inputs;
  26. }
  27. export default defineConfig(({ mode }) => {
  28. const production = (mode === 'production');
  29. const development = (mode === 'development');
  30. return {
  31. build: {
  32. minify: false,
  33. manifest: false,
  34. outDir: 'dist',
  35. rollupOptions: {
  36. input: resolveInputs('./src/pages'),
  37. output: {
  38. manualChunks: undefined,
  39. entryFileNames: 'assets/js/iris/[name].js',
  40. chunkFileNames: 'assets/js/chunks/[name]-[hash].js',
  41. assetFileNames: 'assets/[ext]/[name].[ext]',
  42. },
  43. treeshake: false,
  44. },
  45. sourcemap: (development) ? 'inline': false,
  46. },
  47. resolve: {
  48. alias: {
  49. '$lib': path.resolve('./src/lib'),
  50. },
  51. },
  52. plugins: [
  53. svelte({
  54. emitCss: false,
  55. inspector: development,
  56. }),
  57. viteStaticCopy({
  58. targets: [
  59. // Core
  60. {
  61. src: 'node_modules/bootstrap/dist/js/bootstrap.min.js',
  62. dest: 'assets/js/core',
  63. },
  64. {
  65. src: 'node_modules/jquery/dist/jquery.min.js',
  66. dest: 'assets/js/core',
  67. rename: 'jquery.3.2.1.min.js',
  68. },
  69. {
  70. src: 'node_modules/jquery-validation/dist/jquery.validate.min.js',
  71. dest: 'assets/js/core',
  72. rename: 'jquery.validate.js',
  73. },
  74. {
  75. src: 'node_modules/moment/min/moment.min.js',
  76. dest: 'assets/js/core',
  77. rename: 'moments.min.js',
  78. },
  79. {
  80. src: 'node_modules/popper.js/dist/umd/popper.min.js',
  81. dest: 'assets/js/core',
  82. },
  83. {
  84. src: 'node_modules/socket.io/client-dist/socket.io.min.js',
  85. dest: 'assets/js/core',
  86. rename: 'socket.io.js',
  87. },
  88. {
  89. src: 'node_modules/chart.js/dist/Chart.min.js',
  90. dest: 'assets/js/core',
  91. rename: 'charts.js',
  92. },
  93. // Plugins
  94. {
  95. src: 'node_modules/ace-builds/src-noconflict/',
  96. dest: 'assets/js/plugin/ace/',
  97. },
  98. {
  99. src: 'node_modules/bootstrap-slider/dist/bootstrap-slider.min.js',
  100. dest: 'assets/js/plugin/bootstrap-slider/',
  101. },
  102. {
  103. src: 'node_modules/dropzone/dist/min/dropzone.min.js',
  104. dest: 'assets/js/plugin/dropzone/',
  105. },
  106. {
  107. src: 'node_modules/html2canvas/dist/html2canvas.min.js',
  108. dest: 'assets/js/plugin/html2canvas/',
  109. },
  110. {
  111. src: 'node_modules/jquery.scrollbar/jquery.scrollbar.min.js',
  112. dest: 'assets/js/plugin/jquery-scrollbar/',
  113. },
  114. {
  115. src: 'node_modules/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js',
  116. dest: 'assets/js/plugin/jquery-ui-touch-punch/',
  117. },
  118. {
  119. src: 'node_modules/jqvmap/dist/jquery.vmap.min.js',
  120. dest: 'assets/js/plugin/jqvmap/',
  121. },
  122. {
  123. src: 'node_modules/jqvmap/dist/maps',
  124. dest: 'assets/js/plugin/jqvmap/',
  125. },
  126. {
  127. src: 'node_modules/showdown/dist/showdown.min.js',
  128. dest: 'assets/js/plugin/showdown/',
  129. },
  130. {
  131. src: 'node_modules/sortablejs/Sortable.min.js',
  132. dest: 'assets/js/plugin/sortable/',
  133. rename: 'sortable.js',
  134. },
  135. {
  136. src: 'node_modules/vis/dist/vis.min.js',
  137. dest: 'assets/js/plugin/vis/',
  138. },
  139. {
  140. src: 'node_modules/vis/dist/vis-network.min.js',
  141. dest: 'assets/js/plugin/vis/',
  142. },
  143. {
  144. src: 'node_modules/vis/dist/vis-timeline-graph2d.min.js',
  145. dest: 'assets/js/plugin/vis/',
  146. rename: 'vis.graph.js'
  147. },
  148. {
  149. src: 'node_modules/webfontloader/webfontloader.js',
  150. dest: 'assets/js/plugin/webfont/',
  151. rename: 'webfont.min.js'
  152. },
  153. {
  154. src: 'node_modules/xss/dist/xss.min.js',
  155. dest: 'assets/js/plugin/xss/',
  156. rename: 'xss.js',
  157. },
  158. ]
  159. }),
  160. ],
  161. }
  162. });