Skip to content

Conversation

jaydiablo
Copy link
Contributor

Fixes #183

By adding this property to the project's package.json file, angular-cli will insert it into the dist package.json like so:

"sideEffects": [
    "*.scss",
    "*.css"
  ],

Which tells Webpack that files that match these patterns have side effects, so they shouldn't be tree-shaken.

jaydiablo and others added 2 commits September 3, 2020 08:55
Fixes itsdevdom#183

By adding this property to the project's package.json file, angular-cli will insert it into the dist package.json like so:

```
"sideEffects": [
    "*.scss",
    "*.css"
  ],
```
Which tells Webpack that files that match these patterns have side effects, so they shouldn't be tree-shaken.
@codecov
Copy link

codecov bot commented Mar 10, 2021

Codecov Report

Merging #186 (992c1f6) into develop (19e7e95) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop     #186   +/-   ##
========================================
  Coverage    99.11%   99.11%           
========================================
  Files           14       14           
  Lines          454      454           
  Branches        76       76           
========================================
  Hits           450      450           
  Misses           4        4           

@itsdevdom
Copy link
Owner

Crazy ... I find it interesting enough that ng-packagr / angular-cli adds this property by default, but I would have never guessed that it actually affects files other than plain JavaScript. Webpack being super-intelligent here, I guess. Might explain the issues some people experience with the styles.

Thanks for the PR! Going out in a bug fix release the next days.

@itsdevdom itsdevdom merged commit 7b43cd5 into itsdevdom:develop Mar 10, 2021
fast-facts referenced this pull request in fast-facts/angular-notifier Jun 17, 2022
…s when importing styles (#186)

- Explicitely mark styles (scss, css) as files with side-effects, preventing Webpack from tree shaking them out

Closes #183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sideEffects: false causes imported SCSS file to be optimized away by Webpack 4+
2 participants