Hey there! I'm currently in the process of setting up a Webpack configuration that will generate files for each folder within my project. Unfortunately, creating a separate webpack.config file for each folder is not an option.
So far, I have successfully processed index.html, JS, and SASS files. The next hurdle I'm facing is handling the images.
This is what currently occurs:
cd /MyProject/ && npm run build
Within this directory, there are 'modules', with each module being represented by a folder.
Source Files:
/MyProject/MyModule/src/js/app.js
/MyProject/MyModule/src/scss/app.scss
/MyProject/MyModule/src/index.html
/MyProject/MyModule/src/img/example1.jpg
Distribution Files:
MyProject/MyModule/dist/(app.css|app.js|index.html|img/example1.jpg)
The Issue:
When saving the images using the current method below,
name: '[path]../../dist/img/[name].[ext]'
My HTML output ends up looking like this:
<img src="/MyModule/src/img/../dist/img/screenshot.png" alt="Screenshot">
I do understand why this happens, but I haven't found a more suitable solution yet.
If I remove [path]
, the images get saved inside MyProject instead of MyModule, which is not desired.
webpack.config.js
// Your restructured webpack config code goes here