我一直使用maven和gulp。在maven中,gulp的注射任务在包装罐子时调用。我在src/main/resources/static/
中为项目中的弹簧引导结构放置了静态文件。打包jar后,index.html
文件是这样的:
<!-- build:js js/app.js -->
<!--inject:js -->
<script src="src/main/resources/static/app/.................js"></script>
<!--endinject -->
<!--endbuild -->
我的问题是如何删除脚本src标签中的src/main/resources/static
前缀?
下面的代码是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',
]
},
};
答案 0 :(得分:0)
通过使用src/main/resources/static
在gulp.file.js中设置ignorePath,它将删除index.html中的前缀路径
答案 1 :(得分: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'}))