浏览代码

Server uses vendor.js to connect node_modules to the application in a consistent manner.

dev
Bryan Miller 5 年前
父节点
当前提交
ce88f94994
共有 3 个文件被更改,包括 17 次插入0 次删除
  1. +6
    -0
      server.js
  2. +10
    -0
      vendors.json
  3. +1
    -0
      views/tail.html

+ 6
- 0
server.js 查看文件

@@ -1,4 +1,5 @@
const package = require("./package.json");
const vendors = require("./vendors.json");

const exec = require('child_process').execSync;

@@ -93,6 +94,11 @@ app.set('views', path.join(__dirname, "/views"));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use("/app", express.static(path.join(__dirname, "/app")));
vendors.modules.forEach((m) => {
var p = path.normalize(path.join(__dirname, vendors.default_path, m.path));
var url = path.join(vendors.url_path, m.url_path);
app.use(url, express.static(p));
});
app.use("/app/css/nespaint.css", function(req, res){
res.set("Content-Type", "text/css");
res.send(new Buffer.from(css_output));

+ 10
- 0
vendors.json 查看文件

@@ -0,0 +1,10 @@
{
"url_path":"/app/vendors",
"default_path":"node_modules",
"modules":[
{
"url_path":"ajv",
"path":"ajv/dist"
}
]
}

+ 1
- 0
views/tail.html 查看文件

@@ -1,3 +1,4 @@
</body>
<script src="app/vendors/ajv/ajv.min.js"></script>
<script src="app/js/main.js" type="module"></script>
</html>

正在加载...
取消
保存