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: src/content/concepts/output.mdx
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The minimum requirement for the `output` property in your webpack configuration
20
20
**webpack.config.js**
21
21
22
22
```javascript
23
-
module.exports= {
23
+
exportdefault {
24
24
output: {
25
25
filename:"bundle.js",
26
26
},
@@ -34,9 +34,13 @@ This configuration would output a single `bundle.js` file into the `dist` direct
34
34
If your configuration creates more than a single "chunk" (as with multiple entry points or when using plugins like CommonsChunkPlugin), you should use [substitutions](/configuration/output/#outputfilename) to ensure that each file has a unique name.
35
35
36
36
```javascript
37
-
constpath=require("node:path");
37
+
importpathfrom"node:path";
38
+
import { fileURLToPath } from"node:url";
38
39
39
-
module.exports= {
40
+
const__filename=fileURLToPath(import.meta.url);
41
+
const__dirname=path.dirname(__filename);
42
+
43
+
exportdefault {
40
44
entry: {
41
45
app:"./src/app.js",
42
46
search:"./src/search.js",
@@ -57,7 +61,7 @@ Here's a more complicated example of using a CDN and hashes for assets:
Copy file name to clipboardExpand all lines: src/content/concepts/plugins.mdx
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ contributors:
15
15
16
16
They also serve the purpose of doing **anything else** that a [loader](/concepts/loaders) cannot do. Webpack provides [many such plugins](/plugins/) out of the box.
17
17
18
-
T> When consuming [`webpack-sources`](https://github.com/webpack/webpack-sources) package in plugins, use `require('webpack').sources` instead of `require('webpack-sources')` to avoid version conflicts for persistent caching.
18
+
T> When consuming [`webpack-sources`](https://github.com/webpack/webpack-sources) package in plugins, use `import { sources } from "webpack"` instead of importing from `webpack-sources` to avoid version conflicts for persistent caching.
19
19
20
20
## Anatomy
21
21
@@ -34,7 +34,7 @@ class ConsoleLogOnBuildWebpackPlugin {
34
34
}
35
35
}
36
36
37
-
module.exports= ConsoleLogOnBuildWebpackPlugin;
37
+
exportdefaultConsoleLogOnBuildWebpackPlugin;
38
38
```
39
39
40
40
It is recommended that the first parameter of the tap method of the compiler hook should be a camelized version of the plugin name. It is advisable to use a constant for this so it can be reused in all hooks.
@@ -50,11 +50,15 @@ Depending on how you are using webpack, there are multiple ways to use plugins.
0 commit comments