使用gradle + node插件 + yarn打包vue工程

在vue工程下新建一个build.gradle文件

plugins {
  id "com.github.node-gradle.node" version "1.3.0"
}

//调用yarn run build命令的Gradle任务
task yarnBuild(type: YarnTask, dependsOn: yarn) {
  inputs.files(fileTree('config'))
  inputs.files(fileTree('src'))
  inputs.files(fileTree('static'))
  inputs.files(fileTree('webpack'))
  inputs.file('package.json')
  inputs.file('package-lock.json')

  outputs.files(fileTree('dist'))

  group = 'node'
  args = ['run', 'build']
}

//调用yarn run dev
task yarnDev(type: YarnTask, dependsOn: yarn) {
  group = 'node'
  args = ['run', 'dev']
}

重新 import gradle

然后执行gradle yarnBuild 就相等于 yarn run build

执行gradle yarnDev 就相等于 yarn run dev

你可能感兴趣的:(使用gradle + node插件 + yarn打包vue工程)