webpack.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const Encore = require('@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 sub-directory 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. // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
  22. .enableStimulusBridge('./assets/controllers.json')
  23. // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
  24. .splitEntryChunks()
  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. .enableBuildNotifications()
  37. .enableSourceMaps(!Encore.isProduction())
  38. // enables hashed filenames (e.g. app.abc123.css)
  39. .enableVersioning(Encore.isProduction())
  40. .configureBabel((config) => {
  41. config.plugins.push('@babel/plugin-proposal-class-properties');
  42. })
  43. // enables @babel/preset-env polyfills
  44. .configureBabelPresetEnv((config) => {
  45. config.useBuiltIns = 'usage';
  46. config.corejs = 3;
  47. })
  48. // enables Sass/SCSS support
  49. //.enableSassLoader()
  50. // uncomment if you use TypeScript
  51. //.enableTypeScriptLoader()
  52. // uncomment if you use React
  53. //.enableReactPreset()
  54. // uncomment to get integrity="..." attributes on your script & link tags
  55. // requires WebpackEncoreBundle 1.4 or higher
  56. //.enableIntegrityHashes(Encore.isProduction())
  57. // uncomment if you're having problems with a jQuery plugin
  58. //.autoProvidejQuery()
  59. ;
  60. module.exports = Encore.getWebpackConfig();