What is wrong with this code that combines multiple js files to one?

后端 未结 1 584
走了就别回头了
走了就别回头了 2021-01-21 12:12

I have this node.js code that tries to minify and combine multiple js files to a single js file.

var concat = require(\'gulp-concat\');
var gulp = require(\'gulp         


        
1条回答
  •  梦毁少年i
    2021-01-21 12:52

    Gulpfile.js:

    "use strict";
    
    var concat = require('gulp-concat');
    var gulp = require('gulp');
    var uglify = require('gulp-uglify'); // Add gulp-uglify module to your script
    
    gulp.task('scripts', function() {
        gulp.src('./js/*.js')
            .pipe(concat('all.js'))
            .pipe(uglify())
            .pipe(gulp.dest('./dist/'));
    });
    

    Check package.json dependencies

    Run npm install to verify that all dependencies correctly loaded. I think this was your issue:

    {
        "dependencies": {
            "gulp-concat": "2.x",
            "gulp": "3.x",
            "gulp-uglify": "1.x"
        }
    }
    

    0 讨论(0)
提交回复
热议问题