|
| 1 | +const Encore = require('@symfony/webpack-encore'); |
| 2 | + |
| 3 | +// Manually configure the runtime environment if not already configured yet by the "encore" command. |
| 4 | +// It's useful when you use tools that rely on webpack.config.js file. |
| 5 | +if (!Encore.isRuntimeEnvironmentConfigured()) { |
| 6 | + Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); |
| 7 | +} |
| 8 | + |
| 9 | +Encore |
| 10 | + // directory where compiled assets will be stored |
| 11 | + .setOutputPath('public/build/') |
| 12 | + // public path used by the web server to access the output path |
| 13 | + .setPublicPath('/build') |
| 14 | + // only needed for CDN's or sub-directory deploy |
| 15 | + //.setManifestKeyPrefix('build/') |
| 16 | + |
| 17 | + /* |
| 18 | + * ENTRY CONFIG |
| 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/app.js') |
| 24 | + |
| 25 | + // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js) |
| 26 | + .enableStimulusBridge('./assets/controllers.json') |
| 27 | + |
| 28 | + // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. |
| 29 | + .splitEntryChunks() |
| 30 | + |
| 31 | + // will require an extra script tag for runtime.js |
| 32 | + // but, you probably want this, unless you're building a single-page app |
| 33 | + .enableSingleRuntimeChunk() |
| 34 | + |
| 35 | + /* |
| 36 | + * FEATURE CONFIG |
| 37 | + * |
| 38 | + * Enable & configure other features below. For a full |
| 39 | + * list of features, see: |
| 40 | + * https://symfony.com/doc/current/frontend.html#adding-more-features |
| 41 | + */ |
| 42 | + .cleanupOutputBeforeBuild() |
| 43 | + .enableBuildNotifications() |
| 44 | + .enableSourceMaps(!Encore.isProduction()) |
| 45 | + // enables hashed filenames (e.g. app.abc123.css) |
| 46 | + .enableVersioning(Encore.isProduction()) |
| 47 | + |
| 48 | + .configureBabel((config) => { |
| 49 | + config.plugins.push('@babel/plugin-proposal-class-properties'); |
| 50 | + }) |
| 51 | + |
| 52 | + // enables @babel/preset-env polyfills |
| 53 | + .configureBabelPresetEnv((config) => { |
| 54 | + config.useBuiltIns = 'usage'; |
| 55 | + config.corejs = 3; |
| 56 | + }) |
| 57 | + |
| 58 | + // enables Sass/SCSS support |
| 59 | + //.enableSassLoader() |
| 60 | + |
| 61 | + // uncomment if you use TypeScript |
| 62 | + //.enableTypeScriptLoader() |
| 63 | + |
| 64 | + // uncomment if you use React |
| 65 | + //.enableReactPreset() |
| 66 | + |
| 67 | + // uncomment to get integrity="..." attributes on your script & link tags |
| 68 | + // requires WebpackEncoreBundle 1.4 or higher |
| 69 | + //.enableIntegrityHashes(Encore.isProduction()) |
| 70 | + |
| 71 | + // uncomment if you're having problems with a jQuery plugin |
| 72 | + //.autoProvidejQuery() |
| 73 | +; |
| 74 | + |
| 75 | +module.exports = Encore.getWebpackConfig(); |
0 commit comments