You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/1.documentation/4.utils/2.remove-console-loggers.md
+49-33
Original file line number
Diff line number
Diff line change
@@ -12,13 +12,58 @@ By default, your application will allow log all activity in the browser when you
12
12
ℹ Read more about it [here](https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html#data-to-exclude).
13
13
::
14
14
15
-
Fortunately, `nuxt-security` module removes both `log` and `debug` console outputs by default so your application is not leaking this information.
15
+
Fortunately, the Nuxt Security module removes all `console` outputs by default so your application is not leaking this information.
16
+
Nuxt Security also removes all `debugger` statements from your code.
16
17
17
-
This functionality is delivered by the amazing Vite Plugin by [Talljack](https://github.com/Talljack) that you can check out [here](https://github.com/Talljack/unplugin-remove).
18
+
## Options
19
+
20
+
This feature is enabled globally default.
21
+
22
+
You can disable the feature by setting `removeLoggers: false`:
23
+
24
+
```js{}[nuxt.config.ts]
25
+
export default defineNuxtConfig({
26
+
modules: ['nuxt-security'],
27
+
28
+
security: {
29
+
removeLoggers: false
30
+
}
31
+
})
32
+
```
33
+
34
+
## Alternative method - deprecated
35
+
36
+
By default when you set `removeLoggers: true`, Nuxt Security uses the native Vite features to remove statements.
37
+
38
+
In addition, Nuxt Security also supports an alternative method for removing console outputs, via the amazing `unplugin-remove` Vite Plugin by [Talljack](https://github.com/Talljack) that you can check out [here](https://github.com/Talljack/unplugin-remove).
39
+
40
+
::alert{type="warning"}
41
+
ℹ The `unplugin-remove` method is being deprecated and will be removed in a future release.
42
+
Please note that `unplugin-remove` will not remove `debugger` statements from your code.
43
+
::
44
+
45
+
If you want to use the `unplugin-remove` plugin method, pass an object to the `removeLoggers` configuration instead of passing `true`.
46
+
47
+
```js{}[nuxt.config.ts]
48
+
export default defineNuxtConfig({
49
+
modules: ['nuxt-security'],
50
+
51
+
security: {
52
+
removeLoggers: {
53
+
external: [],
54
+
consoleType: ['log', 'debug'],
55
+
include: [/\.[jt]sx?$/, /\.vue\??/],
56
+
exclude: [/node_modules/, /\.git/]
57
+
}
58
+
}
59
+
})
60
+
```
61
+
62
+
The `removeLoggers` object can be configured with following values.
* don't remove console.log and debugger these module
24
69
*
@@ -47,32 +92,3 @@ export interface Options {
47
92
exclude?:FilterPattern
48
93
}
49
94
```
50
-
51
-
If you would like to add some custom functionality to it, you can do so by doing the following:
52
-
53
-
```js{}[nuxt.config.ts]
54
-
export default defineNuxtConfig({
55
-
modules: ['nuxt-security'],
56
-
57
-
security: {
58
-
removeLoggers: {
59
-
external: [],
60
-
consoleType: ['log', 'debug'],
61
-
include: [/\.[jt]sx?$/, /\.vue\??/],
62
-
exclude: [/node_modules/, /\.git/]
63
-
}
64
-
}
65
-
})
66
-
```
67
-
68
-
However, if you prefer not to have this, you can always disable this functionality from the module configuration (which is not recommended but possible) like the following:
0 commit comments