2

vue-inspect我可以读到这个:

  /* config.module.rule('fonts') */
  {
    test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
    use: [
      /* config.module.rule('fonts').use('url-loader') */
      {
        loader: 'url-loader',
        options: {
          limit: 4096,
          fallback: {
            loader: 'file-loader',
            options: {
              name: 'fonts/[name].[ext]'
            }
          }
        }
      }
    ]
  },

我想将选项更改name'[name].[ext]'删除前缀fonts/

我真的很想知道如何在不删除所有其他选项的情况下更改属性:

  chainWebpack: config => {
    const fontRule = config.module.rule('fonts').use('url-loader')
    fontRule.options({name: 'prout/[name].[ext]'})
  }

似乎一切都在store,但根据webpack-chain手册,

4

1 回答 1

3

Looking at the vue-cli docs it seems to me you can do the following ..

// vue.config.js
module.exports = {
  chainWebpack: config => {
    config.module
      .rule('fonts')
      .use('url-loader')
        .loader('url-loader')
        .tap(options => {
          // modify the options...
          options.fallback.options.name = '[name].[ext]'

          return options
        })
  }
}
于 2019-08-15T11:30:16.180 回答