如何使用create react app和webpack配置manifest.json

时间:2019-05-22 07:35:51

标签: reactjs webpack create-react-app progressive-web-apps

我正在研究react-boilerplate。而且我还用来配置了webpack,但是在集成了webpack之后,我得到了与manifest.json相关的错误。

Manifest: Line: 1, column: 1, Unexpected token.

要解决此问题,我正在使用webpack-pwa-manifest并配置为webpack.config.js https://github.com/arthurbergmz/webpack-pwa-manifest

const manifest = new WebpackPwaManifest({
  name: 'React Starter Kit',
  short_name: 'React Starter Kit',
  description: 'React Starter Kit',
  background_color: '#ffffff',
  start_url: '/',
  scope: '/',
  theme_color: "#3367D6",
  icons: [
    {
      src: path.resolve('public/images/icons/icon-512x512.png'),
      sizes: [96, 128, 192, 256, 384, 512] // multiple sizes
    },
    {
      src: path.resolve('public/images/icons/icon-512x512.png'),
      size: '1024x1024' // you can also use the specifications pattern
    }
  ]
})

看起来是处理此错误的理想方法。

1 个答案:

答案 0 :(得分:0)

您是否也在使用HtmlWebpackPlugin? 清单应自动注入, 确保您没有任何手动添加的清单链接 在您的html模板中。