chore : Simplification de la conf webpack

This commit is contained in:
2024-10-23 12:11:46 +02:00
committed by Gauthier DUPONT
parent fe12b4fc69
commit 5e849ae6f5
3 changed files with 10 additions and 99 deletions

View File

@ -11,11 +11,11 @@ const basePath = process.env.BASE_PATH || ''
// Definition de AppConfig
Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/app/')
.setOutputPath('public/build/')
// public path used by the web server to access the output path
.setPublicPath(basePath + '/build/app')
.setPublicPath(basePath + '/build/')
// only needed for CDN's or sub-directory deploy
.setManifestKeyPrefix('build/app')
.setManifestKeyPrefix('build')
/*
* ENTRY CONFIG
@ -26,6 +26,7 @@ Encore
.addEntry('app', './assets/app.js')
.addEntry('bootstrap-css', './assets/styles/bootstrap.scss')
.addEntry('bootstrap-js', './assets/app-bootstrap.js')
.addEntry('theme','./public/theme-entrypoint.js')
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
.splitEntryChunks()
@ -59,53 +60,6 @@ Encore
.enablePostCssLoader()
.autoProvidejQuery()
.enableSassLoader()
// build the first configuration
const appConfig = Encore.getWebpackConfig();
// Set a unique name for the config (needed later!)
appConfig.name = 'appConfig';
// reset Encore to build the second config
Encore.reset();
// Definition de themeConfig
Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/theme/')
// public path used by the web server to access the output path
.setPublicPath(basePath + '/build/theme')
// only needed for CDN's or sub-directory deploy
.setManifestKeyPrefix('build/theme')
.addEntry('theme','./assets/theme-entrypoint.js')
.addEntry('bootstrap-css', './assets/styles/bootstrap.scss')
.addEntry('bootstrap-js', './assets/app-bootstrap.js')
.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(false)
.enableVersioning(false)
.configureBabel((config) => {
config.plugins.push('@babel/plugin-proposal-class-properties');
})
// enables @babel/preset-env polyfills
.configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage';
config.corejs = 3;
})
.enablePostCssLoader()
.enableSassLoader()
;
// build the second configuration
const themeConfig = Encore.getWebpackConfig();
module.exports = Encore.getWebpackConfig();
// Set a unique name for the config (needed later!)
themeConfig.name = 'themeConfig';
;
// export the final configuration as an array of multiple configurations
module.exports = [appConfig, themeConfig];