Skip to content

Commit

Permalink
New version 0.0.1-beta.17 Read more https://github.com/mappable-world…
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Jul 20, 2023
1 parent ca2e7cf commit 05ef89b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mappable-world/mappable-cli",
"version": "0.0.1-beta.16",
"version": "0.0.1-beta.17",
"description": "Library for encapsulating the logic of autotests and building packages mappable.world js API",
"main": "dist/index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion template/example/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mappable.import.loaders.unshift(async (pkg) => {
}

if (location.href.includes('localhost')) {
await mappable.import.script(`./index.js`);
await mappable.import.script(`/dist/index.js`);
} else {
await mappable.import.script(`https://unpkg.com/${pkg}/dist/index.js`);
}
Expand Down
12 changes: 6 additions & 6 deletions tools/replace.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const path = require('path');
const fs = require('fs');
const stream = require('stream');

module.exports.replaceMiddleware = (middleares, devServer) => {
devServer.app.get('/*', (req, res) => {
module.exports.replaceMiddleware = (dir) => (middleares, devServer) => {
devServer.app.get('/*', (req, res, next) => {
const file = path.join(dir, req.url);

if (!fs.existsSync(file)) {
res.sendStatus(404);
next();
return;
}

Expand All @@ -16,9 +16,9 @@ module.exports.replaceMiddleware = (middleares, devServer) => {
`<html lang="en">
<body>
<ul>${fs
.readdirSync(file)
.map((p) => `<li><a href="${path.join(req.path, p)}">${p}</a></li>`)
.join('')}
.readdirSync(file)
.map((p) => `<li><a href="${path.join(req.path, p)}">${p}</a></li>`)
.join('')}
</ul>
</body>
</html>`
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ module.exports = (args, env, dir = process.cwd()) => {
},
output: {
clean: true,
publicPath: 'dist',
path: path.resolve(dir, 'dist')
},
devServer: {
hot: true,
setupMiddlewares: replaceMiddleware,
setupMiddlewares: replaceMiddleware(dir),
client: {
overlay: true,
progress: true
Expand Down

0 comments on commit 05ef89b

Please sign in to comment.