U
U
uzi_no_uzi2019-09-04 01:32:09
webpack
uzi_no_uzi, 2019-09-04 01:32:09

Why is html not being transferred from src to dist?

There is this `webpack config`,

//dependencies

    const path = require('path');
    const webpack = require('webpack');

    //plugins

    const HtmlWebpackPlugin = require('html-webpack-plugin');

    module.exports = {
    	entry: './src/js/index.js',
    	output: {
    		path: __dirname + '/dist',
    		publicPath: '/',
    		filename: 'bundle.js'
    	},
    	devServer: {
    		contentBase: './dist',
    	},
    	module: {
    		rules: [
    			{
    				test: /\.html$/,
    				use: [
    					{
    						loader: 'html-loader',
    					}
    				]
    			}
    		]
    	},
    	plugins: [
    		new HtmlWebpackPlugin({
    			filename: 'index.html',
    			template: 'src/template/index.html'
    		})
    	]
    }

The `HtmlWebpackPlugin` is supposed to move `index.html` to the `dist` folder, but it doesn't.
The file structure is
-webpack.config.js
-src
--template
---index.html
-dist

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question