webpack html-webpack-plugin syntax error es\html-webpack-plugin\default_index.ejs: Unexpected token (1:0)

first look at the problem
insert image description here

With the exclusion of plug-in dependencies, it was found that html-webpack-plugin and babel-loader conflicted, and
an error message was reported

Module build failed (from ./node_modules/babel-loader/lib/index.js):

es\html-webpack-plugin\default_index.ejs: Unexpected token (1:0)

Therefore, it is necessary to ignore the dependent packages when the project is built, as follows, adding exclude: /node_modules/ configuration under the babel-loader configuration means ignoring the dependent packages.
upper code

        {
    
    
                test: /.js$/,
                exclude: /node_modules/,
                use: {
    
    
                    loader: 'babel-loader',
                    options: {
    
    
                        presets: ['@babel/preset-env']
                    }
                }
            },

Repackaging
insert image description here
successfully solved the above problems

Guess you like

Origin blog.csdn.net/qq_45284938/article/details/128440245