我有一个springboot应用程序,角度js。我创建了一些gulp命令来将js文件uglify为一个名为comperssed.js的文件,
gulp.task('scripts', function() {
gulp.src([ 'src/main/resources/static/scripts/**/*.js'])
.pipe(concat('compressed.js'))
.pipe(stripDebug())
.pipe(uglify({
mangle: true,
compress: true,
output: { beautify: false }
}))
.pipe(gulp.dest('src/main/resources/dist/scripts'));
});
当我运行gulp scripts
它成功创建了comperssed.js时,这就是应用程序在生成的情况下从dist文件夹配置的方式以及在开发时的Static文件夹中,
这是从dist文件夹中缩小的java类配置
@Configuration
public class StaticResourceConfiguration extends WebMvcConfigurerAdapter {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS_PROD = {
"classpath:/dist/" };
private static final String[] CLASSPATH_RESOURCE_LOCATIONS_DEV = {
"classpath:/static/" };
@Value("${fcs.isprod:false}")
private boolean isprod;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (isprod){
registry.addResourceHandler("/**").addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS_PROD);
}
else{
registry.addResourceHandler("/**").addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS_DEV);
}
}
}
我想让应用程序在生产的情况下使用compressed.js。