nuxt.config.js配置

babel

预设在构建客户端/服务端的版本。

默认为 @nuxt/babel-preset-app 在client构建中是ie:'9',在server构建中是node:'current'

build.babel.presets 中配置的预设将应用于客户端和服务器构建。目标将由 Nuxt 相应地设置(客户端/服务器)。如果要为客户端或服务器版本配置不同的预设,请使用presets作为函数: 

export default {
  build: {
    babel: {
      presets({ isServer }) {
        const targets = isServer ? { node: '10' } : { ie: '11' }
        return [[require.resolve('@nuxt/babel-preset-app'), { targets }]]
      }
    }
  }
}

 extend

提供的isClientisServer键与context中可用的键分开, 它们是长期支持的。这里不要使用process.clientprocess.server,因为它们是'undefined'

module.exports = {
  build: {
    extend(config, { isClient }) {
      // 为 客户端打包 进行扩展配置
      if (isClient) {
        config.devtool = 'eval-source-map'
      }
    }
  }
}

相关推荐

  1. Git<span style='color:red;'>配置</span>

    Git配置

    2024-04-14 06:50:05      41 阅读
  2. Redisson配置

    2024-04-14 06:50:05       40 阅读
  3. nginx配置

    2024-04-14 06:50:05       39 阅读
  4. VLAN配置

    2024-04-14 06:50:05       30 阅读
  5. XMLParser配置

    2024-04-14 06:50:05       38 阅读
  6. Redis 配置

    2024-04-14 06:50:05       29 阅读
  7. NAT<span style='color:red;'>配置</span>

    NAT配置

    2024-04-14 06:50:05      35 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-14 06:50:05       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-14 06:50:05       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-14 06:50:05       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-14 06:50:05       18 阅读

热门阅读

  1. React状态与引用(Refs)- 差异和使用场景

    2024-04-14 06:50:05       13 阅读
  2. js实现webp转png/jpg

    2024-04-14 06:50:05       13 阅读
  3. Spring Boot+Vue的高校食材采供管理系统

    2024-04-14 06:50:05       15 阅读
  4. git合并冲突

    2024-04-14 06:50:05       12 阅读
  5. GStreamer插件开发的环境搭建记录

    2024-04-14 06:50:05       14 阅读
  6. 浏览器提示存在不安全脚本如何解决

    2024-04-14 06:50:05       13 阅读
  7. 【C++】模拟list

    2024-04-14 06:50:05       13 阅读
  8. Docker - MongoDB

    2024-04-14 06:50:05       16 阅读
  9. MongoDB聚合运算符:$pow

    2024-04-14 06:50:05       16 阅读
  10. Spring

    2024-04-14 06:50:05       14 阅读