Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

providing custom index.html file for electron-webpack

How can I provide my custom index.html when using electron-webpack ?.

I am new to webpack, I managed to configure it with electron but I didn't have the webpack-dev-server watch my html file so I had to refresh every time I made a change, and this is why I tried electron-webpack.

like image 884
Houss_gc Avatar asked Sep 15 '17 19:09

Houss_gc


People also ask

Can webpack bundle HTML?

To configure Webpack to bundle HTML we'll use our first plugin, a dependency called HtmlWebpackPlugin. Remember, loaders offer functionality to files before Webpack bundles them, whereas plugins modify the entire bundle itself.

What is HTML webpack plugin used for?

The HtmlWebpackPlugin simplifies creation of HTML files to serve your webpack bundles. This is especially useful for webpack bundles that include a hash in the filename which changes every compilation.

What is HTML loader?

The html-loader will parse the URLs, require the images and everything you expect. The extract loader will parse the javascript back into a proper html file, ensuring images are required and point to proper path, and the asset modules will write the .html file for you. Example: webpack.config.js module.

Does Electron use webpack?

Unlike setting up a Webpack project from scratch, electron-webpack comes with a pre-configured Webpack and Babel configuration. It uses @babel/preset-env package to transpile JavaScript for the suitable version of your Electron installation. It also enables HMR for both main and renderer process by default.


1 Answers

First Welcome to Wonderfully Terrible World of Webpack! A powerful tool with a steep learning curve.

Basically any time you want to do anything non-standard (standard being simply bundling JS code together) you're going to need either a plugin or a loader.

For this problem you are trying to make a custom HTML file that webpack is aware of. html-webpack-plugin is going to be the plugin of choice. And adding it to your config file is really simple. If you provide your config I can help you with that or feel free to check out this great resource which will give you a run down of webpack, starting with easy material and getting more complicated as you go. The link below will take you to starting with html-webpack-config.

https://survivejs.com/webpack/developing/getting-started/#setting-up-webpack-configuration

like image 62
DevinFlick Avatar answered Oct 13 '22 12:10

DevinFlick