Webpack ManifestPlugin-字体未正确映射

时间:2019-07-17 09:55:45

标签: css webpack webpack-4 webpack-plugin

我可以简单地描述一下我的设置:我有一些文件是通过文件加载器捆绑在一起的,而另一些则需要通过Webpack-copy-plugin复制。我的项目包含两种字体类型。但是ManifestPlugin只加载一个并错误地映射它。

asset-manifest.json

  "assets/vectorGraphics/seatHeating3.svg": 
  "assets/vectorGraphics/seatHeating3.svg",
  "fonts/app.css": "fonts/myfont.b27af6ba.ttf", // why fonts/app.css?
  "index.html": "index.html"

用于插件的Webpack配置

  new CleanWebpackPlugin(),
      isProduction && new CopyPlugin([
        { from: 'src/assets/', to: 'assets', ignore: ['inline/*'] }
      ]),
      isDevelopment && new webpack.HotModuleReplacementPlugin(),
      isProduction && new MiniCssExtractPlugin({
        filename: 'styles/[name].[contenthash:8].css',
        chunkFilename: 'styles/[name].[contenthash:8].chunk.css'
      }),
      new ManifestPlugin({
        seed: {},
        fileName: 'asset-manifest.json'
      }),

字体的路径在:src-> fonts文件夹中。 并按如下方式使用:

@font-face {
    font-family: 'myfont';
    src: url('../src/fonts/myfont.ttf') format('truetype'); /* Chrome 4+, Firefox 3.5, Opera 10+, Safari 3—5 */
}

@font-face {
    font-family: 'myfont2';
    src: url('../src/fonts/myfont2.ttf') format('truetype'); /* Chrome 4+, Firefox 3.5, Opera 10+, Safari 3—5 */
}

0 个答案:

没有答案