Using Gulp to build requireJS project - gulp-requirejs

前端 未结 7 512
轮回少年
轮回少年 2020-12-12 20:05

I am trying to use gulp-requirejs to build a demo project. I expect result to be a single file with all js dependencies and template included. Here is my gulpfile.js

7条回答
  •  眼角桃花
    2020-12-12 20:12

    Sorry for my english. This solution works for me. (I used gulp-requirejs at my job)

    I think you've forgotten to set mainConfigFile in your gulpfile.js. So, this code will be work

    gulp.task('requirejsBuild', function() {
        rjs({
            name: 'main',
            mainConfigFile: 'path_to_config/config.js',
            baseUrl: './app',
            out: 'result.js'
        })
        .pipe(gulp.dest('app/dist'));
    
    });
    

    In addition, I think when you run that task in gulp, require can not find its config file and

提交回复
热议问题