Run encore without blocking

I have a Symfony project with a lot of scripts and styles. Encore takes about 4 minutes to execute in production:

npm run encore prod

It uses json-manifest-path for versioning. While it’s executing though, I get a 500 response. The error is:

An exception has been thrown during the rendering of a template ("Asset manifest file "XXX/web/build/manifest.json" does not exist.").

This is because the cleanup:

Encore
    .setOutputPath('web/build/')
    .setPublicPath('/build')
    .createSharedEntry('app', './assets/js/app.js')
    .addStyleEntry('style', './assets/css/style.scss')
    // ... more assets here
    .enableSingleRuntimeChunk()
    .cleanupOutputBeforeBuild() // <------------------- cleanup
    .enableSourceMaps(!Encore.isProduction())
    .enableVersioning(Encore.isProduction())
    .enableSassLoader(function(options) {}, { resolveUrlLoader: false })
    .autoProvidejQuery()
;

How am I supposed to avoid this problem?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *