webpack.config.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. .addEntry('vuejs', './assets/js/vuejs.js')
  22. // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
  23. .enableStimulusBridge('./assets/controllers.json')
  24. // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
  25. .splitEntryChunks()
  26. // will require an extra script tag for runtime.js
  27. // but, you probably want this, unless you're building a single-page app
  28. .enableSingleRuntimeChunk()
  29. /*
  30. * FEATURE CONFIG
  31. *
  32. * Enable & configure other features below. For a full
  33. * list of features, see:
  34. * https://symfony.com/doc/current/frontend.html#adding-more-features
  35. */
  36. .cleanupOutputBeforeBuild()
  37. .enableBuildNotifications()
  38. .enableSourceMaps(!Encore.isProduction())
  39. // enables hashed filenames (e.g. app.abc123.css)
  40. .enableVersioning(Encore.isProduction())
  41. .configureBabel((config) => {
  42. config.plugins.push('@babel/plugin-proposal-class-properties');
  43. })
  44. // enables @babel/preset-env polyfills
  45. .configureBabelPresetEnv((config) => {
  46. config.useBuiltIns = 'usage';
  47. config.corejs = 3;
  48. })
  49. // enables Sass/SCSS support
  50. .enableSassLoader()
  51. // uncomment if you use TypeScript
  52. .enableTypeScriptLoader()
  53. .enableVueLoader(() => {}, { runtimeCompilerBuild: true })
  54. // uncomment if you use React
  55. //.enableReactPreset()
  56. // uncomment to get integrity="..." attributes on your script & link tags
  57. // requires WebpackEncoreBundle 1.4 or higher
  58. //.enableIntegrityHashes(Encore.isProduction())
  59. // uncomment if you're having problems with a jQuery plugin
  60. .autoProvidejQuery()
  61. ;
  62. module.exports = Encore.getWebpackConfig();