-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Open
Labels
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-loader
apparently detects dependencies like images, but seems to ignore the.js
files referenced via<script>
tags. - The
.html
file 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).
nevir, musbaig, Flatta, jspopisno1, WestleyArgentum and 240 morebluicezhen and sunrwranchoX, bbologna, zeel, imsasa, bamtron5 and 21 morewebdiscus
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
To be discussed
Status
Priority - Medium