UglifyJS not working in Symfony2 production environment

xil3

I believe I configured it properly -- here is my config.yml:

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    node: "/usr/local/bin/node"
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        uglifyjs2:
            # the path to the uglifyjs executable
            bin: "%kernel.root_dir%/Resources/node_modules/.bin/uglifyjs"
        cssrewrite: ~

I'm storing uglifyjs locally in the project, just to make it easier for distribution.

I am doing the following to generate all the JS files, using uglifyjs:

{% javascripts 
    'vendor/bower_components/jquery/dist/jquery.min.js'
    'vendor/bower_components/bootstrap-sass/assets/javascripts/bootstrap.min.js'
    'vendor/bower_components/angular-route/angular-route.min.js'
    'vendor/bower_components/underscore/underscore-min.js'
    'vendor/bower_components/angular-cookies/angular-cookies.min.js'
    'js/test1.js'
    'js/test2.js'
    filter='?uglifyjs2' %}

    <script src="{{ asset_url }}"></script>

{% endjavascripts %}

If I load the page in dev mode (/app_dev.php), it works fine, and just loads the files individually, but minified by uglifyjs; but if I try to load it in production, it combines all of those js files into one js file (ie. a07da66.js). The problem I'm facing, is that it gets a 404 not found error when trying to load that file (a07da66.js). It tries to access it at js/a07da66.js - seems to create them under js/ by default.

Why does it work fine in app_dev.php, when it creates the new files under js/ (js/a07da66_jquery.min_1.js), but not in production?

lxg

You have to run app/console --env=prod assetic:dump to generate the assets for the prod environment.

Rule of thumb:

  • While in dev mode, keep app/console assetic:watch --force running in the background (at least while working on JS/CSS files). It will regenerate dev assets whenever a file changes.
  • When deploying/building, run app/console --env=prod assetic:dump once in order to have the combined assets for prod generated.

The idea of the prod mode is that you generate some sort of build or snapshot of your current development. Therefore, you would use app/console --env=prod assetic:dump only when creating the build.

Of course, you can switch your dev environment to prod for a brief test, but then you must perform the build procedure, too (which includes generating the prod assets).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Symfony2 Process::start() fails when running in production environment

From Dev

ClearCache command in Symfony2 controller does not work in production environment

From Dev

Nhibernate not working in production environment

From Dev

Geocoder Gem not working in Production Environment

From Dev

jQuery tabs not working in production environment

From Dev

Geocoder Gem not working in Production Environment

From Dev

jQuery tabs not working in production environment

From Dev

Symfony swiftmailer in production environment

From Dev

404 page is working dev environment but not working in Prod environment in Symfony2

From Dev

Symfony2 and production environment - allways displays app_dev in links

From Dev

breadcrumbs with gretel gem working on dev environment but not working on production environment on Heroku

From Dev

Symfony Send email in production environment

From Dev

Bootstrap JavaScript not working in production environment (Rails 4)

From Dev

Rails 4: Image path not working in production environment

From Dev

rails environment production not working no files loaded

From Dev

my .htaccess file is not working (RewriteRule) on wamp but working on production environment

From Dev

Symfony2 Production incorrect "404"

From Dev

Symfony 2 Assetic css and js 404 within production environment

From Dev

Symfony login_check not handled on production environment

From Dev

DATEDIFF not working in Symfony2

From Dev

Translations not working in Symfony2

From Dev

UglifyJS seems to interfere with React dist used in production

From Dev

dispatch.yaml not working for task queue when defaulting production environment

From Dev

Push Notification not working in production environment after switched from sandbox

From Dev

Laravel environment files for local and production possibly not working as intended?

From Dev

why Google Cloud Messaging notification not working with iPhone production environment?

From Dev

Push Notification not working in production environment after switched from sandbox

From Dev

Laravel environment files for local and production possibly not working as intended?

From Dev

Angular2 deploying to production environment questions

Related Related

  1. 1

    Symfony2 Process::start() fails when running in production environment

  2. 2

    ClearCache command in Symfony2 controller does not work in production environment

  3. 3

    Nhibernate not working in production environment

  4. 4

    Geocoder Gem not working in Production Environment

  5. 5

    jQuery tabs not working in production environment

  6. 6

    Geocoder Gem not working in Production Environment

  7. 7

    jQuery tabs not working in production environment

  8. 8

    Symfony swiftmailer in production environment

  9. 9

    404 page is working dev environment but not working in Prod environment in Symfony2

  10. 10

    Symfony2 and production environment - allways displays app_dev in links

  11. 11

    breadcrumbs with gretel gem working on dev environment but not working on production environment on Heroku

  12. 12

    Symfony Send email in production environment

  13. 13

    Bootstrap JavaScript not working in production environment (Rails 4)

  14. 14

    Rails 4: Image path not working in production environment

  15. 15

    rails environment production not working no files loaded

  16. 16

    my .htaccess file is not working (RewriteRule) on wamp but working on production environment

  17. 17

    Symfony2 Production incorrect "404"

  18. 18

    Symfony 2 Assetic css and js 404 within production environment

  19. 19

    Symfony login_check not handled on production environment

  20. 20

    DATEDIFF not working in Symfony2

  21. 21

    Translations not working in Symfony2

  22. 22

    UglifyJS seems to interfere with React dist used in production

  23. 23

    dispatch.yaml not working for task queue when defaulting production environment

  24. 24

    Push Notification not working in production environment after switched from sandbox

  25. 25

    Laravel environment files for local and production possibly not working as intended?

  26. 26

    why Google Cloud Messaging notification not working with iPhone production environment?

  27. 27

    Push Notification not working in production environment after switched from sandbox

  28. 28

    Laravel environment files for local and production possibly not working as intended?

  29. 29

    Angular2 deploying to production environment questions

HotTag

Archive