reactway / scss-bundle

Bundling SCSS files to one bundled file.
MIT License
56 stars 25 forks source link

Ignore unused functions #80

Closed rafmos closed 4 years ago

rafmos commented 5 years ago

Hi,

It would be nice to have an option that is going to ignore functions in imported files that are not used in the entryfile.

Example:

entry-file.scss:

@import "imported-file.scss
$test: my-function1();

imported-file.scss:

@function my-function1() {
  @return (
     color: red;
  );
}

@function my-function2() {
  @return (
     color: blue;
  );
}

The output file should look like this:

@function my-function1() {
  @return (
     color: red;
  );
}

$test: my-function1();

Instead of this:

@function my-function1() {
  @return (
     color: red;
  );
}

@function my-function2() {
  @return (
     color: blue;
  );
}

$test: my-function1();
MartynasZilinskas commented 4 years ago

The initial project feature is bundling all scss source files into one big bundle, so it will be easier to carry around.

So this feature could be implemented in the future, but not anytime soon. Before that, we need to have scss file AST to analyze what was used and what is not.