Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/dev-guide/plugin-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,19 @@ api.onCreateComplete(() => {

Finally, you need to write the content back to the main file:

```js{11}
```js{2,11}
// generator/index.js

api.onCreateComplete(() => {
const { EOL } = require('os')
const fs = require('fs')
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
const lines = contentMain.split(/\r?\n/g)

const renderIndex = lines.findIndex(line => line.match(/render/))
lines[renderIndex] += `\n router,`

fs.writeFileSync(api.entryFile, contentMain, { encoding: 'utf-8' })
fs.writeFileSync(api.entryFile, lines.join(EOL), { encoding: 'utf-8' })
})
```

Expand Down