Skip to content

Commit c9af471

Browse files
committed
fix: typo
1 parent 1d11114 commit c9af471

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/content/plugins/virtual-url-plugin.mdx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Allow creating virtual modules of any type, such as `.ts`, `.json`, `.css`, etc.
1010
<Badge text="5.100.0+" />
1111

1212
```javascript
13-
const webpack = require("webpack)
13+
const webpack = require('webpack');
1414

1515
new webpack.experiments.schemes.VirtualUrlPlugin({
16-
myModule: `export const msg = "from virtual module"`
16+
myModule: `export const msg = "from virtual module"`,
1717
});
1818
```
1919

@@ -30,7 +30,7 @@ console.log(msg);
3030
Create a virtual module that generates build information
3131

3232
```javascript
33-
const webpack = require("webpack)
33+
const webpack = require("webpack")
3434

3535
new webpack.experiments.schemes.VirtualUrlPlugin({
3636
buildInfo: {
@@ -53,11 +53,14 @@ console.log('App version: ', buildTime);
5353
Use custom schema
5454

5555
```javascript
56-
const webpack = require("webpack)
56+
const webpack = require('webpack');
5757

58-
new webpack.experiments.schemes.VirtualUrlPlugin({
59-
myModule: `export const msg = "from virtual module"`
60-
}, "v");
58+
new webpack.experiments.schemes.VirtualUrlPlugin(
59+
{
60+
myModule: `export const msg = "from virtual module"`,
61+
},
62+
'v'
63+
);
6164
```
6265

6366
**src/app.js**
@@ -73,15 +76,15 @@ console.log(msg);
7376
Create multiple virtual modules of different types
7477

7578
```javascript
76-
const webpack = require("webpack)
79+
const webpack = require('webpack');
7780

7881
new webpack.experiments.schemes.VirtualUrlPlugin({
7982
myCssModule: {
80-
type: ".css",
81-
source: "body{background-color: powderblue;}",
83+
type: '.css',
84+
source: 'body{background-color: powderblue;}',
8285
},
8386
myJsonModule: {
84-
type: ".json",
87+
type: '.json',
8588
source: `{"name": "virtual-url-plugin"}`,
8689
},
8790
});
@@ -97,24 +100,24 @@ import 'virtual:myCssModule';
97100
Virtualize the routing file
98101

99102
```javascript
100-
const webpack = require("webpack")
101-
const path = require("path)
102-
const watchDir = path.join(__dirname, "./src/routes")
103+
const webpack = require('webpack');
104+
const path = require('path');
105+
const watchDir = path.join(__dirname, './src/routes');
103106

104107
new webpack.experiments.schemes.VirtualUrlPlugin({
105108
routes: {
106109
source(loaderContext) {
107110
// Use addContextDependency to monitor the addition or removal of subdirectories in watchDir to trigger the rebuilding of virtual modules.
108-
loaderContext.addContextDependency(watchDir)
111+
loaderContext.addContextDependency(watchDir);
109112

110-
const files = fs.readdirSync(watchDir)
113+
const files = fs.readdirSync(watchDir);
111114
return `
112115
export const routes = {
113-
${files.map(key => `${key.split(".")[0]}: () => import('./src/routes/${key}')`).join(",\n")}
116+
${files.map((key) => `${key.split('.')[0]}: () => import('./src/routes/${key}')`).join(',\n')}
114117
}
115-
`
118+
`;
116119
},
117-
}
120+
},
118121
});
119122
```
120123

0 commit comments

Comments
 (0)