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
@@ -80,12 +83,12 @@ Another approach is to replace constants or patterns in your code. We don't reco
80
83
You can use the [@rollup/plugin-replace](https://www.npmjs.com/package/@rollup/plugin-replace) for replacing environment variables in your code. Make sure to add an `include` pattern to avoid processing files unnecessarily.
@@ -42,10 +42,10 @@ Some rollup plugins do expensive operations. During development, this matters a
42
42
The rollup build process assumes that any imported files are meant to be compiled to JS, web dev server serves many different kinds of files to the browser. If you are transforming a non-standard filetype to JS, for example .json files, you need to instruct the server to handle it as a JS file:
Copy file name to clipboardExpand all lines: docs/docs/dev-server/plugins/writing-plugins.md
+21-19
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,9 @@ A plugin is just an object that you add to the `plugins` array in your configura
14
14
In your `web-dev-server.config.js` or `web-test-runner.config.js`:
15
15
16
16
```js
17
-
constawesomePlugin=require('awesome-plugin');
17
+
importawesomePluginfrom'awesome-plugin';
18
18
19
-
module.exports= {
19
+
exportdefault {
20
20
plugins: [
21
21
// use a plugin
22
22
awesomePlugin({ someOption:'someProperty' }),
@@ -99,7 +99,7 @@ Serve an auto generated `index.html`:
99
99
```js
100
100
constindexHTML=generateIndexHTML();
101
101
102
-
module.exports= {
102
+
exportdefault {
103
103
plugins: [
104
104
{
105
105
name:'my-plugin',
@@ -118,7 +118,7 @@ Serve a virtual module:
118
118
```js
119
119
constindexHTML=generateIndexHTML();
120
120
121
-
module.exports= {
121
+
exportdefault {
122
122
plugins: [
123
123
{
124
124
name:'my-plugin',
@@ -135,7 +135,7 @@ module.exports = {
135
135
The file extension is used to infer the mime type to respond with. If you are using a non-standard file extension you need to use the `type` property to set it explicitly:
136
136
137
137
```js
138
-
module.exports= {
138
+
exportdefault {
139
139
plugins: [
140
140
{
141
141
name:'my-plugin',
@@ -163,7 +163,7 @@ The dev server guesses the MIME type based on the file extension. When serving v
163
163
The returned MIME type can be a file extension, this will be used to set the corresponding default MIME type. For example `js` resolves to `application/javascript` and `css` to `text/css`.
164
164
165
165
```js
166
-
module.exports= {
166
+
exportdefault {
167
167
plugins: [
168
168
{
169
169
name:'my-plugin',
@@ -190,7 +190,7 @@ module.exports = {
190
190
You can use a mime type shorthand, such as `js` or `css`. Koa will resolve this to the full mimetype. It is also possible to set the full mime type directly:
191
191
192
192
```js
193
-
module.exports= {
193
+
exportdefault {
194
194
plugins: [
195
195
{
196
196
name:'my-plugin',
@@ -220,7 +220,7 @@ In a web server, the response body is not always a string, but it can be a binar
220
220
Rewrite the base path of your application for local development;
221
221
222
222
```js
223
-
module.exports= {
223
+
exportdefault {
224
224
plugins: [
225
225
{
226
226
name:'my-plugin',
@@ -238,7 +238,7 @@ module.exports = {
238
238
Inject a script to set global variables during local development:
@@ -37,9 +37,9 @@ If you want to customize the puppeteer launcher options, you can add the browser
37
37
You can find all possible launch options in the [official documentation](https://github.com/microsoft/puppeteer/blob/master/docs/api.md#browsertypelaunchoptions)
0 commit comments