【问题标题】:grunt-include-source multiple configurationsgrunt-include-source 多种配置
【发布时间】:2015-04-16 13:54:30
【问题描述】:

我的问题如下;我正在使用 grunt-include-source (https://www.npmjs.com/package/grunt-include-source) 将我的脚本和 css 包含到我的 index.html 中,这工作正常,但我只能指定一个基本路径,我想为 dev 和生产。 (我使用相同的文件夹结构,所以我的 index.html 中没有任何变化,唯一的区别是在我的生产中连接)

 includeSource: {
  options: {
    basePath: 'dev'
  },
  myTarget: {
    files: {
      'dev/index.html': 'app/index.html'
    }
  }

},

上面的代码工作正常,现在我想要 2 个不同的配置,但是在运行任务 includeSource:dev: 时这样的东西不起作用:

 includeSource: {
  dev: {
    options: {
      basePath: 'dev'
     },
     myTarget: {
      files: {
      'dev/index.html': 'app/index.html'
      }
     }
   },
   prod: {
    options: {
      basePath: 'prod'
     },
     myTarget: {
      files: {
      'prod/index.html': 'app/index.html'
      }
     }
   }
},

index.html:

 <!-- include: "type": "js", "files": "scripts/*.js" -->

任何人都可以帮助我如何实现这一目标?

编辑:为了更清楚一点,我在我的生产或开发构建完成后运行这个脚本,对于我的产品/开发,所有脚本都存储在脚本/

亲切的问候,

G

【问题讨论】:

  • 你如何为prod 运行任务?

标签: javascript gruntjs


【解决方案1】:

只需像这样配置您的任务:

includeSource: {
  options: {
    basePath: 'dev/'
  },
  dev: {
    files: {
      'dev/index.html': 'app/index.html'
    }
  },
  prod: {
    options: {
      basePath: 'dist/'
    },
    files: {
      'dist/index.html': 'app/index.html'
    }
  }
},

【讨论】:

  • 然后如何将它用于 dev ?只需输入任务 - includeSource:dev ?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多