eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.25k stars 871 forks source link

Resolves issue #913 . Try to use gulp-cli first #914

Closed Zardoz89 closed 4 years ago

Zardoz89 commented 4 years ago

Summary

Resolves issue #913 . First try to use gulp-cli if it's found on node-modules. If it not exists, then fallbacks to the old behaviour where calls to "node-modules/gulp/bin/gulp.js" that calls the embed gulp-cli of gulp.js

Tests and Documentation

Given this two files :

gulpfile.js

import gulp from "gulp";

const { src, dest } = gulp;

export default() => {
  src('input/*.js')
    .pipe(dest('output/'))
}

package.js

{
  "main": "gulpfile.js",
  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-cli": "^2.3.0"
  },
  "type": "module"
}

It must run correctly and copy any js file from input to output.

eirslett commented 4 years ago

Actually, I don't think people should be using the gulp mojo - a much better alternative is to use the npx mojo/goal, to run gulp. That way, it will work with this Maven plugin in the future, even if gulp breaks in some other way. The same applies to grunt and webpack as well.

Zardoz89 commented 4 years ago

I think that it's a good idea, but should be done on another issue/pull request (as need more changes and proper testing). This could be merged as is it now (and I need ASAP, so I could rewrite my gulpfiles to use ES6 import/export)

eirslett commented 4 years ago

What I mean is, you can do it today with this version of frontend-maven-plugin (it's already supported), you just configure it differently!

Instead of this:

<execution>
    <id>gulp build</id>
    <goals>
        <goal>gulp</goal>
    </goals>
    <configuration>
        <arguments>build</arguments>
    </configuration>
</execution>

you can do this:

<execution>
    <id>gulp build</id>
    <goals>
        <goal>npx</goal>
    </goals>
    <configuration>
        <arguments>gulp build</arguments>
    </configuration>
</execution>
Zardoz89 commented 4 years ago

Oh! Sorry I didn't understand you the first time. I did a little test, and works fine for my case.