Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
htmlWebpackPlugin不';不添加基标记_Webpack_Html Webpack Plugin - Fatal编程技术网

htmlWebpackPlugin不';不添加基标记

htmlWebpackPlugin不';不添加基标记,webpack,html-webpack-plugin,Webpack,Html Webpack Plugin,我正在尝试使用htmlwebpack插件创建一个输出html。下面是我的配置。标题被添加到HTML中,但基本标记没有添加。文档中说插件有一个基本参数,该参数采用字符串值。我是通过与文档中的示例进行类比来完成的,但是标记没有出现在输出文件中。我做错了什么?我找到了一个解决方法,添加了一个模板,在这里我设置了base标记 template: 'src/index.html', 但是我想在没有它的情况下解决这个问题 const path = require('path'); const HtmlWe

我正在尝试使用htmlwebpack插件创建一个输出html。下面是我的配置。标题被添加到HTML中,但基本标记没有添加。文档中说插件有一个基本参数,该参数采用字符串值。我是通过与文档中的示例进行类比来完成的,但是标记没有出现在输出文件中。我做错了什么?我找到了一个解决方法,添加了一个模板,在这里我设置了base标记

template: 'src/index.html',
但是我想在没有它的情况下解决这个问题

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

module.exports = {
    entry: './src/index.js',
    mode: 'production',
    output: {
        path: path.resolve(__dirname, 'public'),
        filename: 'bundle.js'
    },
    module: {
        rules: [
            { test: /\.(js)$/, use: 'babel-loader' },
            { test: /\.(jsx)$/, exclude: /node_modules/, use: 'babel-loader' },
            { test: /\.css$/, loaders: ['style-loader', 'css-loader'] },
            {
                test: /\.(jpe?g|png|gif|svg)$/i,
                use: [
                    'url-loader?limit=10000',
                    'img-loader'
                ]
            }
        ]
    },
    resolve: {
        extensions: ['.js', '.jsx']
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: 'App',
            base: '/',
            filename: 'index.html',
            isProduction: true,
            minify: {
                removeComments: true,
                collapseWhitespace: true,
                removeRedundantAttributes: true,
                useShortDoctype: true,
                removeEmptyAttributes: true,
                removeStyleLinkTypeAttributes: true,
                keepClosingSlash: true,
                minifyJS: true,
                minifyCSS: true,
                minifyURLs: true
            }
        })]
};


我也在寻找同样的,我发现“这个功能只包括在当前的测试版html网页插件4.x中”,我忘了,我也找到了。到今天为止,它工作正常。我正在寻找相同的,我发现“这个功能只包括在当前的测试版html网页插件4.x”我忘了,我还找到了。从今天起,它工作得很好。