0

我一起使用了maven和gulp。在maven中,gulp的注入任务在打包jar时调用。我已经src/main/resources/static/为项目中的 spring boot 结构放置了静态文件。打包jar后,index.html文件是这样的:

<!-- build:js js/app.js -->
<!--inject:js -->
<script src="src/main/resources/static/app/.................js"></script>
<!--endinject -->
<!--endbuild -->

我的问题是如何删除src/main/resources/static脚本 src 标签中的前缀?

下面的代码是 gulp.file.js 中的注入任务:

gulp.task('injection', function () {
    var wiredep = require('wiredep').stream;
    var angularFilesort = require('gulp-angular-filesort');
    var option = gulpConfig.getWireDepOptions();

    return gulp
        .src(gulpConfig.config.indexPage)
        .pipe(wiredep(option))
        .pipe($.inject(
            gulp.src(gulpConfig.config.jsSources.injectable)
                .pipe(angularFilesort()), {ignorePath: '', addRootSlash: false}))
        // .pipe(gulp.dest('./src/main/resources/static/'));
        .pipe(gulp.dest('./src/main/resources/static/'));
});

和 gulp.config.js 中的配置:

var config = {
    buildPath:'',
    styles:[],
    indexPage: client + "index.html",
    browserSync:{
        proxy: 'localhost:' + port,
        port: 3000,
        files: ['**/*.*'],
        ghostMode: { // these are the defaults t,f,t,t
            clicks: true,
            location: false,
            forms: true,
            scroll: true
        },
        logLevel: 'debug',
        logPrefix: 'gulp-patterns',
        notify: true,
        reloadDelay: 1000
    },
    bower: {
        json: require('./bower.json'),
        directory: client+'vendors',
        ignorePath: './../../'
    },
    jsSources: {
        client: client + "app/**/*.js",
        exclude: "!vendors/**/*.js",
        sundry: ['./gulpfile.js', './gulpfile.config.js'],
        injectable: [
            scriptPath + '/quick-sidebar.js',
            scriptPath + '/demo.js',
            scriptPath + '/layout.js',
            scriptPath + '/metronic.js',
            client + 'app/**/*.module.js',
            client + 'app/**/*.js',
            '!' + client + '/app/**/*.spec.js',
        ]
    },
};
4

2 回答 2

0

通过在 gulp.file.js 中设置 ignorePath ,src/main/resources/static它将删除 index.html 中的前缀路径

于 2016-05-09T11:39:56.090 回答
0

在挣扎了很多之后,一个工作

    gulp.src(['app/client/public/index.html']) 
     .pipe(inject(gulp.src(['app/client/public/js/**/*.js','app/client/public/app.js'],{read: false} ),
      {addRootSlash : true,ignorePath:'/app/client/public'}))
于 2017-06-13T18:13:36.083 回答