Webpack 与craco一起使用html网页包插件和favicons网页包插件,但不使用index.html

Webpack 与craco一起使用html网页包插件和favicons网页包插件,但不使用index.html,webpack,create-react-app,html-webpack-plugin,craco,Webpack,Create React App,Html Webpack Plugin,Craco,您好,谢谢您阅读本文 因此,我想使用和的组合将favicons的清单和不同分辨率注入我的应用程序 我正在尝试这种配置 /* craco.config.js */ const HtmlWebpackPlugin = require("html-webpack-plugin"); const FaviconsWebpackPlugin = require("favicons-webpack-plugin"); module.exports = { bab

您好,谢谢您阅读本文

因此,我想使用和的组合将favicons的清单和不同分辨率注入我的应用程序

我正在尝试这种配置

/* craco.config.js */
const HtmlWebpackPlugin = require("html-webpack-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");

module.exports = {
  babel: {
    plugins: [["@babel/plugin-proposal-decorators", { legacy: true }]],
  },
  webpack: {
    plugins: [
      new HtmlWebpackPlugin({
        title: "My App",
        template: "./public/index.html",
        filename: "admin.html",
        meta: {
          viewport: "width=device-width, initial-scale=1, shrink-to-fit=no",
          // Will generate: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
          "theme-color": "#4285f4",
          // Will generate: <meta name="theme-color" content="#4285f4">
        },
      }),
      new HtmlWebpackPlugin({
        title: "My App",
        template: "./public/index.html",
        filename: "admin2.html",
        meta: {
          viewport: "width=device-width, initial-scale=1, shrink-to-fit=no",
          // Will generate: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
          "theme-color": "#4285f4",
          // Will generate: <meta name="theme-color" content="#4285f4">
        },
      }),
      new HtmlWebpackPlugin({
        title: "My App",
        template: "./public/index.html",
        filename: "index.html",
        meta: {
          viewport: "width=device-width, initial-scale=1, shrink-to-fit=no",
          // Will generate: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
          "theme-color": "#4285f4",
          // Will generate: <meta name="theme-color" content="#4285f4">
        },
      }),
      new FaviconsWebpackPlugin({
        logo: "./src/logo.svg", // svg works too!
        prefix: "icons/",
        inject: true,
        favicons: {
          appName: "my-app",
          appDescription: "My awesome App",
          developerName: "Me",
          developerURL: null, // prevent retrieving from the nearest package.json
          background: "#ddd",
          theme_color: "#333",
          icons: {
            coast: false,
            yandex: false,
          },
        },
      }),
    ],
  },
};
/*craco.config.js*/
const HtmlWebpackPlugin=require(“html网页包插件”);
const faviconswebackplugin=require(“faviconswebackplugin”);
module.exports={
巴别塔:{
插件:[“@babel/plugin-proposition-decorators”,{legacy:true}],
},
网页:{
插件:[
新HtmlWebpackPlugin({
标题:“我的应用程序”,
模板:“./public/index.html”,
文件名:“admin.html”,
元:{
视口:“宽度=设备宽度,初始比例=1,收缩以适应=否”,
//将产生:
“主题颜色”:“4285f4”,
//将产生:
},
}),
新HtmlWebpackPlugin({
标题:“我的应用程序”,
模板:“./public/index.html”,
文件名:“admin2.html”,
元:{
视口:“宽度=设备宽度,初始比例=1,收缩以适应=否”,
//将产生:
“主题颜色”:“4285f4”,
//将产生:
},
}),
新HtmlWebpackPlugin({
标题:“我的应用程序”,
模板:“./public/index.html”,
文件名:“index.html”,
元:{
视口:“宽度=设备宽度,初始比例=1,收缩以适应=否”,
//将产生:
“主题颜色”:“4285f4”,
//将产生:
},
}),
新FaviconsWebpackPlugin({
logo:“./src/logo.svg”//svg也能工作!
前缀:“图标/”,
是的,
favicons:{
appName:“我的应用”,
appDescription:“我最棒的应用”,
developerName:“我”,
developerURL:null,//防止从最近的包中检索。json
背景:“ddd”,
主题颜色:“333”,
图标:{
海岸:错,
yandex:错,
},
},
}),
],
},
};
这项测试产生了奇怪的意外结果。在文档admin和admin2中,结果是预期的结果,但在索引上,似乎我的插件被覆盖了

我不确定我是否做得不对,这是我第一次使用。事先非常感谢


你可以在

上看到我的回购协议,我面临着同样的问题,你解决了吗?我面临着同样的问题,你解决了吗?