我可以简单地描述一下我的设置:我有一些文件是通过文件加载器捆绑在一起的,而另一些则需要通过Webpack-copy-plugin复制。我的项目包含两种字体类型。但是ManifestPlugin只加载一个并错误地映射它。
"assets/vectorGraphics/seatHeating3.svg":
"assets/vectorGraphics/seatHeating3.svg",
"fonts/app.css": "fonts/myfont.b27af6ba.ttf", // why fonts/app.css?
"index.html": "index.html"
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 */
}