Skip to content

Commit 00a5bd2

Browse files
committed
add note about side effects and non-JS files
1 parent 0e545a1 commit 00a5bd2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/content/guides/tree-shaking.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ If your code did have some side effects though, an array can be provided instead
130130
}
131131
```
132132
133+
T> Note that any imported file is subject to tree shaking. This means if you use something like `css-loader` in your project and import a CSS file, it needs to be added to the side effect list so it will not be accidentally dropped:
134+
135+
```json
136+
{
137+
"name": "your-project",
138+
"sideEffects": [
139+
"./src/some-side-effectful-file.js",
140+
"*.css"
141+
]
142+
}
143+
```
144+
133145
## Minify the Output
134146
135147
So we've cued up our "dead code" to be dropped by using the `import` and `export` syntax, but we still need to drop it from the bundle. To do that, we'll use the `-p` (production) webpack compilation flag to enable the uglifyjs minification plugin.

0 commit comments

Comments
 (0)