-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from cmux/0.13
0.13.10
- Loading branch information
Showing
9 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
const fs = require('fs-extra') | ||
const fs = require('fs-extra'); | ||
|
||
const { dll } = require('../../defaults/dev-request-uri') | ||
const { dll } = require('../../defaults/dev-request-uri'); | ||
const getDevRoutes = require('../../libs/get-dev-routes'); | ||
|
||
/** | ||
* 扩展 webpack-dev-server | ||
* @param {Object} server | ||
*/ | ||
module.exports = (app) => { | ||
module.exports = app => { | ||
getDevRoutes().forEach(({ file, route }) => { | ||
app.get(`${route}`, function(req, res) { | ||
res.type('application/javascript'); | ||
res.send(fs.readFileSync(file)); | ||
}); | ||
}); | ||
// console.log({files}) | ||
// console.log(server) | ||
// return | ||
const { KOOT_DEV_DLL_FILE_CLIENT: fileDll } = process.env | ||
const { KOOT_DEV_DLL_FILE_CLIENT: fileDll } = process.env; | ||
if (fileDll && fs.existsSync(fileDll)) | ||
app.get(`${dll}`, function (req, res) { | ||
res.type('application/javascript') | ||
res.send(fs.readFileSync(fileDll)) | ||
}) | ||
} | ||
app.get(`${dll}`, function(req, res) { | ||
res.type('application/javascript'); | ||
res.send(fs.readFileSync(fileDll)); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
|
||
const getDirDevDll = require('./get-dir-dev-dll'); | ||
|
||
/** | ||
* @typedef {Object} RouteMap | ||
* @property {string} file - 硬盘路径 | ||
* @property {string} route - 访问路由/pathname | ||
*/ | ||
|
||
/** | ||
* _仅针对开发环境_ 获取静态文件路由,这些文件通常临时生成并保存在硬盘中 | ||
* @return {RouteMap[]} | ||
*/ | ||
module.exports = () => { | ||
if (process.env.WEBPACK_BUILD_ENV !== 'dev') return []; | ||
|
||
const dirDevDll = getDirDevDll(); | ||
|
||
return glob | ||
.sync(path.resolve(dirDevDll, '**/*'), { | ||
dot: true | ||
}) | ||
.map(file => { | ||
let route = path.relative(dirDevDll, file); | ||
if (route.substr(0, 1) !== '/') route = '/' + route; | ||
return { | ||
file, | ||
route | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters