webpack: Incorrect line endings on bundles

On OS X, with webpack 1.12.0, my bundles are getting created with CRLF line-endings rather than the OS X specific LF line-endings. This is causing Git to barf on adds with a fatal: CRLF would be replaced by LF in <somefile>

Any ideas? Need more info?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 30
  • Comments: 28 (7 by maintainers)

Most upvoted comments

We have .css bundle resulting having mixed ending lines. It seems it preserve line ending of each imported module. Would be nice to have a feature to normalize line ending in compiled bundle. (js and css)

Bump. We’re also seeing this issue. We want to ensure that our line endings are normalized throughout our codebase by using a .gitattributes with * text=auto but it looks like webpack is packing our bundles using CRLF. Is there a configuration option (can there be a configuration option?) to set line endings when bundling to avoid the issue?

We use webpack in three different machines: Windows 10, OS X, Ubuntu. Bundles have different line endings depending where they were generated. As result files consider different even if they differ by line endings only.

Observation:

One Windows machine generate bundle with CRLF and another Windows machine generate with LF on the same code base.

The Windows that generate LF had git config core.eol = lf generate bundle with LF ,
while git config core.eol = nothing generate bundle with CRLF

Possible solution

On Windows using Command Prompt

  1. git config --global core.autocrlf false
  2. git config --global core.eol lf
  3. Close command prompt (This seems necessary)
  4. Clone the repository again
  5. Build the bundle

The new bundle will now has LF ending consistently

Holy hell, a 3-year-old bug report with zero investigation by the dev team? C’mon guys!