Browse Source

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

dev
Bryan Miller 5 years ago
parent
commit
ce88f94994
3 changed files with 17 additions and 0 deletions
  1. +6
    -0
      server.js
  2. +10
    -0
      vendors.json
  3. +1
    -0
      views/tail.html

+ 6
- 0
server.js View File

@@ -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 View File

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

+ 1
- 0
views/tail.html View File

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

Loading…
Cancel
Save