Code: Select all
import express from 'express';
import dotenv from 'dotenv';
import bodyParser from 'body-parser';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import path from 'path';
dotenv.config();
import { compileSassAndSaveMultiple } from 'compile-sass';
const PORT = process.env.PORT || 3000;
const app = express();
const __dirname = dirname(fileURLToPath(import.meta.url));
app.use('/', express.static(path.join(__dirname, 'public'))); // for delivering static resources
app.use(bodyParser.urlencoded({ extended: false })); // for working with forms
app.use(express.json()); // for parsing json data
await compileSassAndSaveMultiple({
sassPath: path.join(__dirname, 'public/scss/'),
cssPath: path.join(__dirname, 'public/css/'),
files: ['main.scss'],
});
app.use('/', (req, res, next) => {
res.sendFile(path.join(__dirname, 'views/index.html'));
});
app.listen(PORT, () => console.log(`Listening on port: ${PORT}`));
< /code>
von HTML -Datei, die gesendet wird:
[*]
Tracker App
node_modules/
[*] src/
public /
Assets /< /li>
CSS /
< ul>
main.css
- scss /< /li>
main.scss
< /ul>
< /li>
< /ul>
< /li>
< /ul>
[*]Index.js
< /ul>
< /li>
< /ul>
Jede Hilfe wäre geschätzt!
Ich habe viele Artikel und Stackoverflow -Beiträge übersehen, die sich einem ähnlichen Problem nähern, aber keine der Lösungen hat funktioniert.