Skip to content

Commit

Permalink
feat: support watching
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn committed Jul 14, 2018
1 parent d8a8344 commit 1f9134d
Show file tree
Hide file tree
Showing 5 changed files with 566 additions and 9 deletions.
26 changes: 23 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"testRegex": "/test/.+\\.spec\\.(js|ts)$",
"modulePathIgnorePatterns": [
"<rootDir>/index.js",
"<rootDir>/test/fixtures/"
],
"moduleFileExtensions": [
Expand All @@ -46,8 +47,10 @@
}
},
"devDependencies": {
"@types/fs-extra": "^5.0.4",
"@types/jest": "^22.2.2",
"@types/webpack": "^4.4.5",
"fs-extra": "^6.0.1",
"jest": "^22.4.3",
"prettier": "1.11.1",
"ts-jest": "^22.4.2",
Expand Down
7 changes: 5 additions & 2 deletions src/webpack-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ class VueAutoRoutingPlugin {
}

apply(compiler: Compiler) {
compiler.hooks.run.tap(pluginName, () => {
const generate = () => {
const code = generateRoutes(this.options)
const to = path.resolve(__dirname, '../index.js')
fs.writeFileSync(to, code)
})
}

compiler.hooks.run.tap(pluginName, generate)
compiler.hooks.watchRun.tap(pluginName, generate)
}
}

Expand Down

0 comments on commit 1f9134d

Please sign in to comment.