在 React 和 webpack 中包含 manifest.js 而不是 manifest.json

时间:2021-05-10 18:41:37

标签: reactjs webpack manifest manifest.json

我能找到的所有解决方案都在谈论manifest.json。我可能会出错,但在我的 manifest.js 中,我的 `manifest.js 中有一些需求,所以我认为它不可能是一个 json 文件。


我尝试将其包含在我的 webpack.config.js 中,但进行了灯塔审核,它仍然显示“未获取清单”

  {
    test: /manifest.js$/,
    use: [
      {
        loader: "file-loader",
        options: {
          name: "ui/[name].[hash].json",
        },
      },
      "extract-loader",
    ],
  },

这是我的manifest.js

const Icon192 = require("../images/icon-192x192.png");
const Icon512 = require("../images/icon-512x512.png")

const manifest = {
  icons: [
    {
      src: Icon192,
      sizes: "192x192",
      type: "image/png",
    },
    {
      src: Icon512,
      sizes: "512x512",
      type: "image/png",
    },
  ],
  name: "My_App",
  short_name: "My_App",
  orientation: "portrait",
  display: "standalone",
  start_url: "/",
  theme_color: "    #228B22",
  background_color: "#ffffff",
  description: "Any Maskable",
  start_url: "https://example.com",
  display: "browser",
  prefer_related_applications: false
};

module.exports = JSON.stringify(manifest, null, 2);

如果我不需要这些要求,并且可以用不同的方式做到这一点,请告诉我

0 个答案:

没有答案
相关问题