鍍金池/ 問答/網(wǎng)絡安全  HTML/ html-webpack-plugin插件該如何修改favicon的輸出路徑?

html-webpack-plugin插件該如何修改favicon的輸出路徑?

在用webpack的時候,想要使用html-webpack-plugin來注入favicon,但是輸出路徑是output.path的,不知道怎么改

代碼

const webpack = require('webpack');
const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');
const cleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
    entry: 'app/scripts/main.js',
    output: {
        filename: 'bundle.js',
        path: 'dist/scripts'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['react', 'es2015'] 
                    }
                }
            }
        ]
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin(),
        new htmlWebpackPlugin({
            favicon:'app/favicon.ico', 
            filename:"dist/index.html",
            template: 'app/index.html'
        }),
        new cleanWebpackPlugin(['dist'])
    ]
}
回答
編輯回答
嫑吢丕

陷入邏輯陷阱了,只想改html-webpack-plugin中的配置,其實可以把output改一下

output:{
    path:'dist',
    filename:'scripts/bundle.js'
}
2018年5月28日 15:49