我一起使用了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',
]
},
};