先修改 config/index.js文件,将 assetsPublicPath 的 ‘/’ 改为 ‘./’

卸载现有的element-ui,重新安装

npm uninstall element-ui
npm install element-ui
若不行,则继续往下看

由下图可知,通过url-loader将 woff2?|eot|ttf|otf 相关文件打包到 fonts/ 目录下;

在这里插入图片描述

代码
{
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
        }
      }

这里用到的utils,来自vue-cli的生成的项目文件,和webpack.base.conf.js同一级目录。

ExtractTextPlugin.extract配置的情况

在 build/utils 文件中的下图所示位置添加 publicPath: ‘…/…/’

在这里插入图片描述

代码
if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader',
        publicPath: '../../'
      })
    } else {
      return ['vue-style-loader'].concat(loader)
    }

没有ExtractTextPlugin.extract配置的情况

在这里插入图片描述


if (options.extract) {
      loaders.push({
        loader: MiniCssExtractPlugin.loader,
        options: {
          publicPath: '../../'
        }
      })
    } else {
      loaders.push('vue-style-loader')
    }
Logo

前往低代码交流专区

更多推荐