Advertisement
Guest User

Untitled

a guest
Jan 29th, 2023
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. const { join } = require('path')
  2. const Encore = require('@symfony/webpack-encore')
  3.  
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Encore runtime environment
  7. |--------------------------------------------------------------------------
  8. */
  9. if (!Encore.isRuntimeEnvironmentConfigured()) {
  10. Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev')
  11. }
  12.  
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Output path
  16. |--------------------------------------------------------------------------
  17. |
  18. | The output path for writing the compiled files. It should always
  19. | be inside the public directory, so that AdonisJS can serve it.
  20. |
  21. */
  22. Encore.setOutputPath('./build/inertia/ssr')
  23.  
  24. /*
  25. |--------------------------------------------------------------------------
  26. | Public URI
  27. |--------------------------------------------------------------------------
  28. |
  29. | The public URI to access the static files. It should always be
  30. | relative from the "public" directory.
  31. |
  32. */
  33. Encore.setPublicPath('/ssr')
  34.  
  35. /*
  36. |--------------------------------------------------------------------------
  37. | Entrypoints
  38. |--------------------------------------------------------------------------
  39. |
  40. | Entrypoints are script files that boots your frontend application. Ideally
  41. | a single entrypoint is used by majority of applications. However, feel
  42. | free to add more (if required).
  43. |
  44. | Also, make sure to read the docs on "Assets bundler" to learn more about
  45. | entrypoints.
  46. |
  47. */
  48. Encore.addEntry('ssr', './resources/js/ssr.tsx')
  49.  
  50. /*
  51. |--------------------------------------------------------------------------
  52. | Isolated entrypoints
  53. |--------------------------------------------------------------------------
  54. |
  55. | Treat each entry point and its dependencies as its own isolated module.
  56. |
  57. */
  58. Encore.disableSingleRuntimeChunk()
  59.  
  60. /*
  61. |--------------------------------------------------------------------------
  62. | Cleanup output folder
  63. |--------------------------------------------------------------------------
  64. |
  65. | It is always nice to cleanup the build output before creating a build. It
  66. | will ensure that all unused files from the previous build are removed.
  67. |
  68. */
  69. Encore.cleanupOutputBeforeBuild()
  70.  
  71. /*
  72. |--------------------------------------------------------------------------
  73. | Assets versioning
  74. |--------------------------------------------------------------------------
  75. |
  76. | Enable assets versioning to leverage lifetime browser and CDN cache
  77. |
  78. */
  79. Encore.enableVersioning(Encore.isProduction())
  80.  
  81. /*
  82. |--------------------------------------------------------------------------
  83. | Configure dev server
  84. |--------------------------------------------------------------------------
  85. |
  86. | Here we configure the dev server to enable live reloading for edge templates.
  87. | Remember edge templates are not processed by Webpack and hence we need
  88. | to watch them explicitly and livereload the browser.
  89. |
  90. */
  91. Encore.configureDevServerOptions((options) => {
  92. /**
  93. * Normalize "options.static" property to an array
  94. */
  95. if (!options.static) {
  96. options.static = []
  97. } else if (!Array.isArray(options.static)) {
  98. options.static = [options.static]
  99. }
  100.  
  101. /**
  102. * Enable live reload and add views directory
  103. */
  104. options.liveReload = true
  105. options.static.push({
  106. directory: join(__dirname, './resources/js/pages'),
  107. watch: true,
  108. })
  109. })
  110.  
  111. /*
  112. |--------------------------------------------------------------------------
  113. | CSS precompilers support
  114. |--------------------------------------------------------------------------
  115. |
  116. | Uncomment one of the following lines of code to enable support for your
  117. | favorite CSS precompiler
  118. |
  119. */
  120. // Encore.enableSassLoader()
  121. // Encore.enableLessLoader()
  122. // Encore.enableStylusLoader()
  123.  
  124. /*
  125. |--------------------------------------------------------------------------
  126. | CSS loaders
  127. |--------------------------------------------------------------------------
  128. |
  129. | Uncomment one of the following line of code to enable support for
  130. | PostCSS or CSS.
  131. |
  132. */
  133. Encore.enablePostCssLoader()
  134. //Encore.configureCssLoader(() => {})
  135.  
  136. Encore.enableTypeScriptLoader()
  137. Encore.enableReactPreset()
  138.  
  139. /*
  140. |--------------------------------------------------------------------------
  141. | Enable Vue loader
  142. |--------------------------------------------------------------------------
  143. |
  144. | Uncomment the following lines of code to enable support for vue. Also make
  145. | sure to install the required dependencies.
  146. |
  147. */
  148. // Encore.enableVueLoader(() => {}, {
  149. // version: 3,
  150. // runtimeCompilerBuild: false,
  151. // useJsx: false,
  152. // })
  153.  
  154. /*
  155. |--------------------------------------------------------------------------
  156. | Configure logging
  157. |--------------------------------------------------------------------------
  158. |
  159. | To keep the terminal clean from unnecessary info statements , we only
  160. | log warnings and errors. If you want all the logs, you can change
  161. | the level to "info".
  162. |
  163. */
  164. const config = Encore.getWebpackConfig()
  165. config.infrastructureLogging = {
  166. level: 'warn',
  167. }
  168. config.stats = 'errors-warnings'
  169.  
  170. /*
  171. |--------------------------------------------------------------------------
  172. | SSR Config
  173. |--------------------------------------------------------------------------
  174. |
  175. */
  176. config.externals = [require('webpack-node-externals')()]
  177. config.externalsPresets = { node: true }
  178. config.output = {
  179. libraryTarget: 'commonjs2',
  180. filename: 'ssr.js',
  181. path: join(__dirname, './build/inertia/ssr'),
  182. }
  183. config.experiments = { outputModule: true }
  184.  
  185. /*
  186. |--------------------------------------------------------------------------
  187. | Export config
  188. |--------------------------------------------------------------------------
  189. |
  190. | Export config for webpack to do its job
  191. |
  192. */
  193.  
  194. module.exports = config
  195.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement