webpack.config.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var 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('/tff/build')
  12. // only needed for CDN's or sub-directory deploy
  13. .setManifestKeyPrefix('build/')
  14. /*
  15. * ENTRY CONFIG
  16. *
  17. * Add 1 entry for each "page" of your app
  18. * (including one that's included on every page - e.g. "app")
  19. *
  20. * Each entry will result in one JavaScript file (e.g. app.js)
  21. * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
  22. */
  23. .addEntry('app', './assets/js/app.js')
  24. //.addEntry('page1', './assets/js/page1.js')
  25. //.addEntry('page2', './assets/js/page2.js')
  26. // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
  27. .splitEntryChunks()
  28. // will require an extra script tag for runtime.js
  29. // but, you probably want this, unless you're building a single-page app
  30. .enableSingleRuntimeChunk()
  31. /*
  32. * FEATURE CONFIG
  33. *
  34. * Enable & configure other features below. For a full
  35. * list of features, see:
  36. * https://symfony.com/doc/current/frontend.html#adding-more-features
  37. */
  38. .cleanupOutputBeforeBuild()
  39. .enableBuildNotifications()
  40. .enableSourceMaps(!Encore.isProduction())
  41. // enables hashed filenames (e.g. app.abc123.css)
  42. .enableVersioning(Encore.isProduction())
  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 to get integrity="..." attributes on your script & link tags
  53. // requires WebpackEncoreBundle 1.4 or higher
  54. //.enableIntegrityHashes(Encore.isProduction())
  55. // uncomment if you're having problems with a jQuery plugin
  56. //.autoProvidejQuery()
  57. // uncomment if you use API Platform Admin (composer req api-admin)
  58. .enableReactPreset()
  59. //.addEntry('admin', './assets/js/admin.js')
  60. ;
  61. module.exports = Encore.getWebpackConfig();