1

Hello I wish compile Vue files with Gulp, so far I've used gulp, webpack and webpack-stream which did the trick, my Vue compiling was set through webpack.config.js and webpack-stream was great for that.

But since I updated package.json and Vue to rely on vue-cli-service and vue.config.js I have to compile with 'npm run ...script andrun "vue-cli-service build".

I've managed to get it working like this:

In gulpfile.js

gulp.task('site-js', siteJS);

function siteJS() {
    return gulp.src('src/js/**.js')
        .pipe(plumber())
        .pipe(webpack(webpackConfig))
        .pipe(gulpif(globalVars.productionBuild, uglify()))
        .pipe(gulp.dest(destDir));
}

In package.json

"scripts": {
    "build-dev": "gulp build-dev",
    "build": "gulp build",
    "css": "gulp css",
    "js": "gulp js",
    "vuejs": "./node_modules/.bin/vue-cli-service build ./src/vue/app.js",
    "dev": "gulp watch",
},

This works fine when I run 'gulp build' but it does not support 'gulp watch' as when .exac() is run from gulp watch state it crashes.

Is there a way to run vue build from code using vue-cli-service?

  • You can call 'vue-cli-service build' (or any npm) command when a specific Gulp task is run: https://stackoverflow.com/a/55206501/247670 – Ali Jul 20 '21 at 14:02

0 Answers0