-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
I'm trying to figure out what's the best way to make webpack aware of the main HTML file (for a single page app).
AFAIK i have these options:
specify an .js file as entry point
That JS file needs to have require("./index.html"); so that the HTML file is identified as an dependency and included in the build.
To support that I have the following Webpack configuration:
loaders : {
{ test: /\.html/, loader: 'file?name=[name].[ext]' }
}Problems:
- Seems awkward to me to define the HTML file as a dependency for a JS file (instead of the other way round)
- Additional dependencies in the HTML code (like images) are not being identified.
specify the .html file as entry point and using file-loader for HTML files
Problems:
- Dependencies aren't being detected and thus no JavaScript code is bundled.
specify the .html file as entry point and using html-loader for HTML files
See sample config here: https://gist.github.com/jampy/44faf0c18fd64b6dd1fd
..and the HTML file: https://gist.github.com/jampy/a2dd493901cd6dc5ae8b
Problems:
- The
html-loaderapparently detects dependencies like images, but seems to ignore the.jsfiles referenced via<script>tags. - The
.htmlfile itself is converted to JavaScript and included in the .js file, which is useless.
What's correct?
What am I supposed to do to let webpack handle the HTML file and it's dependencies (including JavaScript).
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status