diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index f0fb551..d55f5e3 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -56,16 +56,6 @@ module.exports = { limit: 10000, 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]' - } } ] }, diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 070ae22..26cec99 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -13,9 +13,18 @@ const portfinder = require('portfinder') const HOST = process.env.HOST 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, { 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 devtool: config.dev.devtool, diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 475c3ca..3264a28 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -13,13 +13,24 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin') 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, { module: { rules: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true, usePostCSS: true - }) + }).concat([iconFontLoader]) }, devtool: config.build.productionSourceMap ? config.build.devtool : false, output: {