Fix loader for icon font

This commit is contained in:
ZaneYork 2020-10-23 14:25:01 +08:00
parent 75ee0f632b
commit f6975b4fec
3 changed files with 22 additions and 12 deletions

View File

@ -56,16 +56,6 @@ module.exports = {
limit: 10000, limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]') name: utils.assetsPath('media/[name].[hash:7].[ext]')
} }
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader:'url-loader',
options:{
limit: 10000,
outputPath: utils.assetsPath('fonts'),//决定打包出来的文件的路径 在 dist 下的路径
publicPath:'../fonts/',
name:'[name].[ext]'
}
} }
] ]
}, },

View File

@ -13,9 +13,18 @@ const portfinder = require('portfinder')
const HOST = process.env.HOST const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT) const PORT = process.env.PORT && Number(process.env.PORT)
const iconFontLoader = {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[ext]')
}
}
const devWebpackConfig = merge(baseWebpackConfig, { const devWebpackConfig = merge(baseWebpackConfig, {
module: { module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true}).concat([iconFontLoader])
}, },
// cheap-module-eval-source-map is faster for development // cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool, devtool: config.dev.devtool,

View File

@ -13,13 +13,24 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = require('../config/prod.env') const env = require('../config/prod.env')
const iconFontLoader = {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader:'url-loader',
options:{
limit: 10000,
outputPath: utils.assetsPath('fonts'),//决定打包出来的文件的路径 在 dist 下的路径
publicPath:'../fonts/',
name:'[name].[ext]'
}
}
const webpackConfig = merge(baseWebpackConfig, { const webpackConfig = merge(baseWebpackConfig, {
module: { module: {
rules: utils.styleLoaders({ rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap, sourceMap: config.build.productionSourceMap,
extract: true, extract: true,
usePostCSS: true usePostCSS: true
}) }).concat([iconFontLoader])
}, },
devtool: config.build.productionSourceMap ? config.build.devtool : false, devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: { output: {