how to make angular Js app with springboot take from gulp uglification file

295 Views Asked by At

i have a springboot app , angular js . i created some gulp commands to uglify the js files into one file called 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'));
    });

when i run gulp scripts it's successfully create the comperssed.js , this is how the application configurd to take from the dist folder in case of production and Static folder in case of development , this is the java class configuration to take minified from dist folder

@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);
        }

    }
}

i want to make the application take the compressed.js in case of production .

0

There are 0 best solutions below