You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently have the following file structure: emodelle.html located in the de folder takes the element from de/components/02_footer_section/index.html and injects its contents into itself.
de/emodelle.html
de/components/02_footer_section/index.html
de/emodelle.html
DATA FROM FOOTER:
<%= require('html-loader!./components/02_footer_section/index.html').default %>
DATA STRAIGHT FROM EMODELLE:
<%= htmlWebpackPlugin.options.newVariable %>
</main>
When using the npm run dev command, the newVariable variable appears correctly from emodelle.html, but not from footer, but when I go directly to the footer file in the browser, I see the rendered variable.
It seems that when compiling, webpack only renders emodelle and takes its variables, while from footer it does not render anything, it only shows pure html as a string in emodelle.html
GOAL TO ACHIEVE
I would like to be able to add dynamic variables to the file de/components/02_footer_section/index.html which will then be rendered when compiling to emodelle.html
The text was updated successfully, but these errors were encountered:
mateusz-grek
changed the title
How to render two files at once by injecting one into the other?
Does not render a file that is used in another module.
Feb 1, 2024
mateusz-grek
changed the title
Does not render a file that is used in another module.
File does not render correctly / cannot get variable from options
Feb 1, 2024
Because html-loader doesn't support variables, it is a future of html-webpack-plugin, you need to pass variables into <%= require('html-loader!./components/02_footer_section/index.html').default %>
There is an old issue - webpack-contrib/html-loader#291, I recommend to use template engine for such purposes, we are still not sure it is a right solution to allow using require inside HTML files, that is why it is not finished and don't work in some cases
Current behaviour 💣
I currently have the following file structure: emodelle.html located in the de folder takes the element from de/components/02_footer_section/index.html and injects its contents into itself.
de/emodelle.html
de/components/02_footer_section/index.html
This dynamic variable
newVariable
comes from webpack.config.jsWebpack.config.js
Expected behaviour ☀️
When using the
npm run dev
command, thenewVariable
variable appears correctly from emodelle.html, but not from footer, but when I go directly to the footer file in the browser, I see the rendered variable.It seems that when compiling, webpack only renders emodelle and takes its variables, while from footer it does not render anything, it only shows pure html as a string in emodelle.html
GOAL TO ACHIEVE
I would like to be able to add dynamic variables to the file de/components/02_footer_section/index.html which will then be rendered when compiling to emodelle.html
Reproduction Example 👾
Environment 🖥
The text was updated successfully, but these errors were encountered: