You'll find alot of ressources about setting up "vanilla" webpack configurations to suit your needs on the internet. However, I'm having a hard time adapting those "vanilla" webpack solutions for use with webpack-encore!
Here's an example with configuring webpack to generate HTML assets out of TWIG/JSON source files.
So far, I managed to make it work by using webpack-encore's .addLoader() and .addPlugin() built-in methods. But there's a huge caveat: my adaptation is pretty much static as I have to manually declare a new plugin for each TWIG page I want to be rendered as HTML:
Encore
[...]
.addLoader({
test: /\.twig$/,
type: 'asset/source',
loader: 'twig-html-loader'
})
.addPlugin(new HtmlWebpackPlugin({
title: 'Index',
filename: '../html/index.html',
template: './assets/twig/index.twig',
publicPath: '../build/'
}))
.addPlugin(new HtmlWebpackPlugin({
title: 'Bio',
filename: '../html/pages/bio.html',
template: './assets/twig/bio.twig',
publicPath: '../../build/'
}))
;
"vanilla" webpack configuration's sample is much better as the author wrote and made use of two custom functions that recursively read through the main twig directory and make a list of the templates in all the folders, keeping the paths intact and excluding all the template files.
This is my very first experience with webpack/webpack-encore and I have absolutely no clue about how to use those vanilla javascript "walk" and "htmlPlugins" function with webpack-encore.
Any help, even keywords to guide me to new Google searches paths, would be greatly appreciated. Thanks!