Dan503 / gulp-auto-imports

Auto generate import-only files for any file type. SCSS, JS, TS, Pug, whatever you want.
MIT License
1 stars 0 forks source link

Provide the ability to re-order imports #1

Closed Dan503 closed 6 years ago

Dan503 commented 6 years ago

In CSS the order that styles are written in matters significantly.

Currently, if you use gulp-file-loader to load scss files. You have no easy way of adjusting the order that the modules are loaded in. This is a pretty big problem for a language where order is so critically important.

Dan503 commented 6 years ago

Still need to update the readme with new instructions about how to use the new feature.

  1. Apply retainOrder: true setting
  2. Save the output in git
  3. Move lines up and down inside the file
  4. File imports that no longer exist will be removed
  5. New file imports will be added to the bottom of the list.
Dan503 commented 6 years ago

I needed to introduce a breaking change to get this feature working.

Before, you were able to use $path in your format setting as many times as you wanted. This made it incredibly difficult to explain in regex where one import began and another one ended due to how many types of characters are allowed to be used in a file name.

To simplify this, I have restricted the $path placeholder to only being used once per format setting. I can't really think of a reason why you would need to announce a path more than once per file so I don't see any issues arising from this.

Even though I highly doubt anyone has used the $path setting more than once in a format setting, this is still a breaking change so it needs to be treated as such.

Dan503 commented 6 years ago

Fixed in v2.0.0