F
F
Fatoblack2017-06-27 17:00:53
JavaScript
Fatoblack, 2017-06-27 17:00:53

How to configure webpack for layout?

With setting up a webpack for a project in which you only need to write in js (for example, react.js), everything is clear. But how can I make it so that I can make changes directly in index.html inside the build folder (which webpack-dev-server serves) so that webpack-dev-server reacts to them?
I understand that I’m most likely doing some kind of perversion and it’s much easier to set up browsersync on a gallop, but I still wanted to know how to work directly with html in webpack.
htmlWebpackPlugin simply makes it possible to specify some separate parts of the html file, but does not allow full layout.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ozknemoy, 2017-06-27
@Fatoblack

using loader. but you need to import html into js otherwise it won't work

{
            test: /\.html$/,
            use: [
                // Reference: https://github.com/webpack/raw-loader
                // Allow loading html through js
                {loader: 'raw-loader'}
            ]
        }

and for index.html its plugin HtmlWebpackPlugin. but the old galp or browsersync is better. when the application is huge, you don't need to rebuild the scripts every time if you added a small element to the layout. that is, live reload works an order of magnitude faster

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question