249

Since I first saw a dist/ directory in many open source projects, usually on GitHub, I've been wondering what it means.

With dist, vendor, lib, src, and many other folder names that we see quite often, I sometimes wonder how I should name my own folders.

Correct me if I'm wrong!

  • src: Contains the sources. Sometimes only the pure sources, sometimes with the minified version, depends on the project.
  • vendor: Contains other dependencies, like other open source projects.
  • lib: Good question, it's really close to vendor actually, depending on the project we can see one or another or both...
  • dist: From what I saw, it contains the "production" files, the one we should use if we want to use the library.

Why is open source so confusing? Isn't it possible to do things clearer? At least per language because some languages use specific names.

2
  • 4
    Another good answer can be found here. Commented Jan 6, 2016 at 16:25
  • I really should get into the habit of including this in my git repos, instead of worrying about building jars after 3 years of not working on something. Commented Dec 29, 2023 at 1:36

4 Answers 4

442

To answer your question:

/dist means "distributable", the compiled code/library.

Folder structure varies by build system and programming language. Here are some standard conventions:

  • src/: "source" files to build and develop the project. This is where the original source files are located, before being compiled into fewer files to dist/, public/ or build/.

  • dist/: "distribution", the compiled code/library, also named public/ or build/. The files meant for production or public use are usually located here.

    There may be a slight difference between these three:

    • build/: is a compiled version of your src/ but not a production-ready.
    • dist/: is a production-ready compiled version of your code.
    • public/: usually used as the files runs on the browser. which it may be the server-side JS and also include some HTML and CSS.
  • assets/: static content like images, video, audio, fonts etc.

  • lib/: external dependencies (when included directly).

  • test/: the project's tests scripts, mocks, etc.

  • node_modules/: includes libraries and dependencies for JS packages, used by Npm.

  • vendor/: includes libraries and dependencies for PHP packages, used by Composer.

  • bin/: files that get added to your PATH when installed.

Markdown/Text Files:

  • README.md: A help file which addresses setup, tutorials, and documents the project. README.txt is also used.
  • LICENSE.md: any rights given to you regarding the project. LICENSE or LICENSE.txt are variations of the license file name, having the same contents.
  • CONTRIBUTING.md: how to help out with the project. Sometimes this is addressed in the README.md file.

Specific (these could go on forever):

  • package.json: defines libraries and dependencies for JS packages, used by Npm.
  • package-lock.json: specific version lock for dependencies installed from package.json, used by Npm.
  • composer.json: defines libraries and dependencies for PHP packages, used by Composer.
  • composer.lock: specific version lock for dependencies installed from composer.json, used by Composer.
  • gulpfile.js: used to define functions and tasks to be run with Gulp.
  • .travis.yml: config file for the Travis CI environment.
  • .gitignore: Specification of the files meant to be ignored by Git.
9
  • 43
    What about the meaning of dist? Commented Apr 4, 2014 at 12:45
  • 30
    distribution, it usually contains the compiled software.
    – 0xcaff
    Commented Apr 4, 2014 at 14:01
  • 5
    What about the assets/ folder? What is supposed to contain?
    – Sekhemty
    Commented Mar 15, 2019 at 23:30
  • 3
    @Sekhemty, static content like images, video, audio, fonts etc.
    – Quaker
    Commented May 28, 2019 at 7:35
  • 1
    @Vadorequest um, it's in the answer
    – crxyz
    Commented Apr 5, 2021 at 13:32
88

To answer your original question about the meaning of the dist folder:

The shortform dist stands for distributable and refers to a directory where files will be stored that can be directly used by others without the need to compile or minify the source code that is being reused.

Example: If I want to use the source code of a Java library that someone wrote, then you need to compile the sources first to make use of it. But if a library author puts the already compiled version into the repository, then you can just go ahead. Such an already compiled version is saved into the dist directory.

Something similar applies to JavaScript modules. Usually JavaScript code is minified and obfuscated for use in production. Therefore, if you want to distribute a JavaScript library, it's advisable to put the plain (not minified) source code into an src (source) directory and the minified and obfuscated version into the dist (distributable) directoy, so others can grab the minified version right away without having to minify it themselves.

Note: Some developers use names like target, build or dest (destination) instead of dist. But the purpose of these folders is identical.

1
  • 14
    I think this best answers the question. dist stands for distributable, not distribution. It is the directory that once everything ha been compiled, gulped, transpiled, assembled and produced from all the other sources and files and trinkets etc.. this is what you want to distribute or indicate to others that it is the distributable! Commented Feb 25, 2016 at 16:46
4

Summary of the folders:

  • bin: binaries
  • contrib: contributions to the project
  • dist: -- see 1. and 2.
  • doc/s: documentation
  • include: headers (C/C++)
  • lib: libraries (C/C++)
  • man: short for man/manual pages (Unix/Linux), c.f. man(1)
  • src: source

  1. "/dist means "distributable", the compiled code/library." ref.
  2. "The shortform dist stands for distributable and refers to a directory where files will be stored that can be directly used by others without the need to compile or minify the source code that is being reused." ref.
3

Actually, "dist folder" is the result you get after modifying source code with "npm run build" or "ng build" or "ng build --prod" for production.

Meanwhile, after getting a "dist folder", there might still be few a things that you still need to do depending on your project type.

1
  • 1
    It is perhaps worth to mention that actually(!), it depends 🤞. Technically on the node package manager (npm) script named "build" which the npm-run command runs. In practice, this differs (a lot), we've seen in node projects the preference of the directory "build" - and not "dist" - for example, while having the "dist" folder already available before any npm build script has been run (e.g. a clean checkout).
    – hakre
    Commented Jan 20, 2023 at 11:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.