webpack.config.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import Encore from '@symfony/webpack-encore';
  2. // Manually configure the runtime environment if not already configured yet by the "encore" command.
  3. // It's useful when you use tools that rely on webpack.config.js file.
  4. if (!Encore.isRuntimeEnvironmentConfigured()) {
  5. Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
  6. }
  7. Encore
  8. // directory where compiled assets will be stored
  9. .setOutputPath('public/build/')
  10. // public path used by the web server to access the output path
  11. .setPublicPath('/build')
  12. // only needed for CDN's or subdirectory deploy
  13. //.setManifestKeyPrefix('build/')
  14. /*
  15. * ENTRY CONFIG
  16. *
  17. * Each entry will result in one JavaScript file (e.g. app.js)
  18. * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
  19. */
  20. .addEntry('app', './assets/app.js')
  21. // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
  22. .splitEntryChunks()
  23. // enables the Symfony UX Stimulus bridge (used in assets/stimulus_bootstrap.js)
  24. .enableStimulusBridge('./assets/controllers.json')
  25. // will require an extra script tag for runtime.js
  26. // but, you probably want this, unless you're building a single-page app
  27. .enableSingleRuntimeChunk()
  28. /*
  29. * FEATURE CONFIG
  30. *
  31. * Enable & configure other features below. For a full
  32. * list of features, see:
  33. * https://symfony.com/doc/current/frontend.html#adding-more-features
  34. */
  35. .cleanupOutputBeforeBuild()
  36. // Displays build status system notifications to the user
  37. .enableBuildNotifications()
  38. .enableSourceMaps(!Encore.isProduction())
  39. // enables hashed filenames (e.g. app.abc123.css)
  40. .enableVersioning(Encore.isProduction())
  41. // Configure JS and CSS minimizers
  42. // .configureJsMinimizerPlugin((options, MinimizerPlugin) => {
  43. // options.minify = MinimizerPlugin.esbuildMinify
  44. // })
  45. // .configureCssMinimizerPlugin((options, MinimizerPlugin) => {
  46. // options.minify = MinimizerPlugin.lightningCssMinify;
  47. // })
  48. // configure Babel
  49. .configureBabel((config) => {
  50. config.plugins.push(['polyfill-corejs3', { method: 'usage-pure', version: '3.49' }]);
  51. })
  52. // enables Sass/SCSS support
  53. .enableSassLoader()
  54. // uncomment if you use TypeScript
  55. //.enableTypeScriptLoader()
  56. // uncomment if you use React
  57. //.enableReactPreset()
  58. // uncomment to get integrity="..." attributes on your script & link tags
  59. // requires WebpackEncoreBundle 1.4 or higher
  60. //.enableIntegrityHashes(Encore.isProduction())
  61. // uncomment if you're having problems with a jQuery plugin
  62. .autoProvidejQuery()
  63. ;
  64. export default await Encore.getWebpackConfig();