Skip to content

ng serve removes /dist directory, but I would like to have it under version control #4366

Closed

Description

@stepanzarubin

angular-cli@1.0.0-beta.28.3

Activity

  1. grizzm0 commented on Feb 2, 2017

    @grizzm0
    Contributor

    This was done on purpose in #4293. Any reason why you would want dist in VCS?

    Without a build before committing the build would be out of sync with the current revision anyhow.

  2. stepanzarubin commented on Feb 3, 2017

    @stepanzarubin
    Author

    @grizzm0 because dist is synonym of an actual build, and it is, ng serve serves the actual code base, but not the build, build is done once per week, month, etc. and has nothing to do with a current working directory. Another synonym of a dist is release, a lot of packages/libraries put their releases under dist directory and have it under version control.

    Also, having dist under VCS allows us to keep everything in one place.

  3. stepanzarubin commented on Feb 3, 2017

    @stepanzarubin
    Author

    ng serve should accomplish its own task => serve actual code. And suddenly it starts to remove files from the outside? this is weird, the other developer was confused, to get rid of a confusion it is enough to understand that there is nothing under dist directory when ng serve is running, README can be updated to clarify this.

    At least, removing dist should not be a default behavior, can be achieved by specific configuration option or a command argument.

    Thanks.

  4. grizzm0 commented on Feb 3, 2017

    @grizzm0
    Contributor

    It was changed as alot of people thought ng serve would serve the dist folder if present.

    @filipesilva You got any input on this?

  5. stepanzarubin commented on Feb 3, 2017

    @stepanzarubin
    Author

    @grizzm0 then, why to have a dist folder at all? what is a purpose of it? temporary folder for temporary content? let`s take a look at scenario:

    1. I make build: ng build --env prod which will write it under dist folder
    2. Then I run ng serve and my build is gone... wow

    Why do I stop ng serve at all to make a build?

  6. grizzm0 commented on Feb 3, 2017

    @grizzm0
    Contributor

    Build is part of my deploy flow. I guess that's how most people use it.

  7. stepanzarubin commented on Feb 3, 2017

    @stepanzarubin
    Author

    @grizzm0 what will happen if build was not successful? for any reason, build can output files successfully, but they may not work (e.g. local build is ok, but there is something wrong with prod one).

  8. stepanzarubin commented on Feb 3, 2017

    @stepanzarubin
    Author

    I believe each command should remove/update only files this command is working with. ng build can clean build directory, but not other command.

  9. grizzm0 commented on Feb 3, 2017

    @grizzm0
    Contributor

    If tests fail during deploy the deploy will be cancelled. If it builds successfully but something is wrong I would either store x releases on the prod machine or rollback by checking out a previous tag and build from that.

  10. stepanzarubin commented on Feb 3, 2017

    @stepanzarubin
    Author

    The world is not perfect, tests does not cover everything perfectly, some people do not write tests.

  11. grizzm0 commented on Feb 3, 2017

    @grizzm0
    Contributor

    You could still rollback by tag or keep releases on your prod server. :p

  12. filipesilva commented on Feb 3, 2017

    @filipesilva
    Contributor

    I'm sorry this change disrupted your workflow. We're not looking at changing it back though.

    dist/ had, at best your last ng build and was never reflective of ng serve.

    My recommendation for your particular case is to do make a build using the --output-path (-op) flag and keep that one under version control.

    ng build --output-path=last-build/
    
  13. mzeromski commented on Mar 7, 2017

    @mzeromski

    My solution for this:

    After update Jan 2017 noticed new problem. Command ng serve remove /dist dir.

    Solution:

    File: package.json (new command prod-build)

    "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "prod-build": "ng build --output-path=last-build/ --env=prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
    },
    File: angular-cli.json (change ourDir)

    "outDir": "/tmp/dist",

    To build your prod version run: npm run prod-build

    To serve: ng serve

    In this configuration: ng server will create tmp dir, and your project directory will be clean, even when you commit changes without stop ng serve.

  14. lgellert commented on Apr 12, 2017

    @lgellert

    Having the latest production build in /dist was part of my build process too. By setting up a command in package.json as @Hinol suggested that sends it to a custom folder (/dist-prod/), I can live with it, minimal changes elsewhere.

    My command is:
    "build-prod": "ng build --prod --env=prod --output-path=dist-prod/" note the extra --prod flag, which does the uglifying and tree shaking.

  15. 20 remaining items

  16. EliezerB123 commented on Mar 18, 2018

    @EliezerB123

    Running "ng build --output-path='../'" , instead of creating a directory in the parent named "dist", just deleted 12 hours of my work.

    A little warning, or maybe an error message would have been nice.

    Instead, AFTER my entire project was deleted, I got a cheery little message saying "Path must be a string. Received null"

  17. michaelb-01 commented on May 9, 2018

    @michaelb-01

    Has the delete-output-path flag been removed in Angular CLI 6.0.0?

  18. rsheptolut commented on May 9, 2018

    @rsheptolut

    It also seems Angular CLI 6.0.0 stopped deleting the "dist" folder by default. Had to add rmdir .\\dist /S /Q && to my npm start script before ng serve, because oddly enough I've depended on the old behavior 🙂

  19. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  20. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions